File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -574,8 +574,25 @@ export default class Wrapper implements BaseWrapper {
574574 )
575575 }
576576
577- // Don't fire event on a disabled element
578- if ( this . attributes ( ) . disabled ) {
577+ /**
578+ * Avoids firing events on specific disabled elements
579+ * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
580+ */
581+
582+ const supportedTags = [
583+ 'BUTTON' ,
584+ 'COMMAND' ,
585+ 'FIELDSET' ,
586+ 'KEYGEN' ,
587+ 'OPTGROUP' ,
588+ 'OPTION' ,
589+ 'SELECT' ,
590+ 'TEXTAREA' ,
591+ 'INPUT'
592+ ]
593+ const tagName = this . element . tagName
594+
595+ if ( this . attributes ( ) . disabled && supportedTags . indexOf ( tagName ) > - 1 ) {
579596 return
580597 }
581598
Original file line number Diff line number Diff line change @@ -123,16 +123,21 @@ describeWithShallowAndMount('trigger', mountingMethod => {
123123 it ( 'does not fire on disabled elements' , ( ) => {
124124 const clickHandler = sandbox . stub ( )
125125 const TestComponent = {
126- template : '<button disabled @click="clickHandler"/>' ,
126+ template :
127+ '<div><button disabled @click="clickHandler"/><a href="#" disabled @click="clickHandler"/></div>' ,
127128 props : [ 'clickHandler' ]
128129 }
129130 const wrapper = mountingMethod ( TestComponent , {
130131 propsData : {
131132 clickHandler
132133 }
133134 } )
134- wrapper . trigger ( 'click' )
135+
136+ wrapper . find ( 'button' ) . trigger ( 'click' )
135137 expect ( clickHandler . called ) . to . equal ( false )
138+
139+ wrapper . find ( 'a' ) . trigger ( 'click' )
140+ expect ( clickHandler . called ) . to . equal ( true )
136141 } )
137142
138143 it ( 'handles .prevent' , ( ) => {
You can’t perform that action at this time.
0 commit comments