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 @@ -192,6 +192,12 @@ module.exports = {
192192 */
193193
194194 update : function ( data ) {
195+ if ( process . env . NODE_ENV !== 'production' && ! _ . isArray ( data ) ) {
196+ _ . warn (
197+ 'v-repeat pre-converts Objects into Arrays, and ' +
198+ 'v-repeat filters should always return Arrays.'
199+ )
200+ }
195201 if ( this . componentId ) {
196202 var state = this . componentState
197203 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