File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ Directive.prototype._bind = function () {
88
88
if ( this . literal ) {
89
89
this . update && this . update ( descriptor . raw )
90
90
} else if (
91
- this . expression &&
91
+ ( this . expression || this . modifiers ) &&
92
92
( this . update || this . twoWay ) &&
93
93
! this . _checkStatement ( )
94
94
) {
Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ module.exports = {
62
62
} ,
63
63
64
64
update : function ( handler ) {
65
+ // stub a noop for v-on with no value,
66
+ // e.g. @mousedown .prevent
67
+ if ( ! this . descriptor . raw ) {
68
+ handler = function ( ) { }
69
+ }
70
+
65
71
if ( typeof handler !== 'function' ) {
66
72
process . env . NODE_ENV !== 'production' && _ . warn (
67
73
'v-on:' + this . arg + '="' +
Original file line number Diff line number Diff line change @@ -144,6 +144,16 @@ if (_.inBrowser) {
144
144
expect ( prevented ) . toBe ( true )
145
145
} )
146
146
147
+ it ( 'prevent modifier with no value' , function ( ) {
148
+ new Vue ( {
149
+ el : el ,
150
+ template : '<a href="#123" @click.prevent>'
151
+ } )
152
+ var hash = window . location . hash
153
+ trigger ( el . firstChild , 'click' )
154
+ expect ( window . location . hash ) . toBe ( hash )
155
+ } )
156
+
147
157
it ( 'multiple modifiers working together' , function ( ) {
148
158
var outer = jasmine . createSpy ( 'outer' )
149
159
var prevented
You can’t perform that action at this time.
0 commit comments