File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
test/unit/specs/directives/for Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,12 @@ module.exports = {
7070 } ,
7171
7272 update : function ( data ) {
73+ if ( process . env . NODE_ENV !== 'production' && ! _ . isArray ( data ) ) {
74+ _ . warn (
75+ 'v-for pre-converts Objects into Arrays, and ' +
76+ 'v-for filters should always return Arrays.'
77+ )
78+ }
7379 this . diff ( data )
7480 this . updateRef ( )
7581 this . updateModel ( )
Original file line number Diff line number Diff line change @@ -660,6 +660,22 @@ if (_.inBrowser) {
660660 expect ( hasWarned ( _ , 'It seems you are using two-way binding' ) ) . toBe ( true )
661661 } )
662662
663+ it ( 'warn filters that return non-Array values' , function ( ) {
664+ new Vue ( {
665+ el : el ,
666+ template : '<div v-for="item in items | test"></div>' ,
667+ data : {
668+ items : [ ]
669+ } ,
670+ filters : {
671+ test : function ( val ) {
672+ return { }
673+ }
674+ }
675+ } )
676+ expect ( hasWarned ( _ , 'should always return Arrays' ) ) . toBe ( true )
677+ } )
678+
663679 it ( 'nested track by' , function ( done ) {
664680 var vm = new Vue ( {
665681 el : el ,
You can’t perform that action at this time.
0 commit comments