File tree 2 files changed +22
-0
lines changed
test/unit/specs/directives/for
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,12 @@ module.exports = {
70
70
} ,
71
71
72
72
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
+ }
73
79
this . diff ( data )
74
80
this . updateRef ( )
75
81
this . updateModel ( )
Original file line number Diff line number Diff line change @@ -660,6 +660,22 @@ if (_.inBrowser) {
660
660
expect ( hasWarned ( _ , 'It seems you are using two-way binding' ) ) . toBe ( true )
661
661
} )
662
662
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
+
663
679
it ( 'nested track by' , function ( done ) {
664
680
var vm = new Vue ( {
665
681
el : el ,
You can’t perform that action at this time.
0 commit comments