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 @@ -26,6 +26,15 @@ module.exports = {
26
26
*/
27
27
28
28
bind : function ( ) {
29
+ // friendly warning...
30
+ var filters = this . filters
31
+ if ( filters && filters . read && ! filters . write ) {
32
+ _ . warn (
33
+ 'It seems you are using a read-only filter with ' +
34
+ 'v-model. You might want to use a two-way filter ' +
35
+ 'to ensure correct behavior.'
36
+ )
37
+ }
29
38
var el = this . el
30
39
var tag = el . tagName
31
40
var handler
Original file line number Diff line number Diff line change @@ -473,5 +473,18 @@ if (_.inBrowser) {
473
473
expect ( _ . warn ) . toHaveBeenCalled ( )
474
474
} )
475
475
476
+ it ( 'warn read-only filters' , function ( ) {
477
+ var vm = new Vue ( {
478
+ el : el ,
479
+ template : '<input v-model="abc | test">' ,
480
+ filters : {
481
+ test : function ( v ) {
482
+ return v
483
+ }
484
+ }
485
+ } )
486
+ expect ( _ . warn ) . toHaveBeenCalled ( )
487
+ } )
488
+
476
489
} )
477
490
}
You can’t perform that action at this time.
0 commit comments