File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,12 @@ module.exports = {
202202 */
203203
204204 update : function ( data ) {
205+ if ( process . env . NODE_ENV !== 'production' && ! _ . isArray ( data ) ) {
206+ _ . warn (
207+ 'v-repeat pre-converts Objects into Arrays, and ' +
208+ 'v-repeat filters should always return Arrays.'
209+ )
210+ }
205211 if ( this . componentId ) {
206212 var state = this . componentState
207213 if ( state === UNRESOLVED ) {
Original file line number Diff line number Diff line change @@ -802,6 +802,22 @@ if (_.inBrowser) {
802802 } )
803803 } )
804804
805+ it ( 'warn filters that return non-Array values' , function ( ) {
806+ new Vue ( {
807+ el : el ,
808+ template : '<div v-repeat="items | test"></div>' ,
809+ data : {
810+ items : [ ]
811+ } ,
812+ filters : {
813+ test : function ( val ) {
814+ return { }
815+ }
816+ }
817+ } )
818+ expect ( hasWarned ( _ , 'should always return Arrays' ) ) . toBe ( true )
819+ } )
820+
805821 } )
806822}
807823
You can’t perform that action at this time.
0 commit comments