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 = {
202
202
*/
203
203
204
204
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
+ }
205
211
if ( this . componentId ) {
206
212
var state = this . componentState
207
213
if ( state === UNRESOLVED ) {
Original file line number Diff line number Diff line change @@ -802,6 +802,22 @@ if (_.inBrowser) {
802
802
} )
803
803
} )
804
804
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
+
805
821
} )
806
822
}
807
823
You can’t perform that action at this time.
0 commit comments