File tree 4 files changed +18
-2
lines changed
test/unit/specs/directives 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ Directive.prototype._bind = function () {
106
106
if ( this . _literal ) {
107
107
this . update && this . update ( this . expression )
108
108
} else if (
109
- this . _watcherExp &&
109
+ ( this . _watcherExp || this . modifiers ) &&
110
110
( this . update || this . twoWay ) &&
111
111
( ! this . isLiteral || this . _isDynamicLiteral ) &&
112
112
! this . _checkStatement ( )
Original file line number Diff line number Diff line change @@ -74,6 +74,12 @@ module.exports = {
74
74
} ,
75
75
76
76
update : function ( handler ) {
77
+ // stub a noop for v-on with no value,
78
+ // e.g. @mousedown .prevent
79
+ if ( ! this . _descriptor . raw ) {
80
+ handler = function ( ) { }
81
+ }
82
+
77
83
if ( typeof handler !== 'function' ) {
78
84
process . env . NODE_ENV !== 'production' && _ . warn (
79
85
'v-on:' + this . arg + '="' +
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ exports.parse = function (s) {
81
81
inSingle = inDouble = false
82
82
curly = square = paren = 0
83
83
lastFilterIndex = 0
84
- dir = { }
84
+ dir = { raw : s }
85
85
86
86
for ( i = 0 , l = str . length ; i < l ; i ++ ) {
87
87
c = str . charCodeAt ( i )
Original file line number Diff line number Diff line change @@ -126,6 +126,16 @@ if (_.inBrowser) {
126
126
expect ( prevented ) . toBe ( true )
127
127
} )
128
128
129
+ it ( 'prevent modifier with no value' , function ( ) {
130
+ new Vue ( {
131
+ el : el ,
132
+ template : '<a href="#123" @click.prevent>'
133
+ } )
134
+ var hash = window . location . hash
135
+ trigger ( el . firstChild , 'click' )
136
+ expect ( window . location . hash ) . toBe ( hash )
137
+ } )
138
+
129
139
it ( 'multiple modifiers working together' , function ( ) {
130
140
var outer = jasmine . createSpy ( 'outer' )
131
141
var prevented
You can’t perform that action at this time.
0 commit comments