diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js
index 956227a8b..2a7326d8c 100644
--- a/packages/test-utils/src/wrapper.js
+++ b/packages/test-utils/src/wrapper.js
@@ -574,8 +574,25 @@ export default class Wrapper implements BaseWrapper {
)
}
- // Don't fire event on a disabled element
- if (this.attributes().disabled) {
+ /**
+ * Avoids firing events on specific disabled elements
+ * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
+ */
+
+ const supportedTags = [
+ 'BUTTON',
+ 'COMMAND',
+ 'FIELDSET',
+ 'KEYGEN',
+ 'OPTGROUP',
+ 'OPTION',
+ 'SELECT',
+ 'TEXTAREA',
+ 'INPUT'
+ ]
+ const tagName = this.element.tagName
+
+ if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
return
}
diff --git a/test/specs/wrapper/trigger.spec.js b/test/specs/wrapper/trigger.spec.js
index 79c78511c..f16514b89 100644
--- a/test/specs/wrapper/trigger.spec.js
+++ b/test/specs/wrapper/trigger.spec.js
@@ -120,19 +120,47 @@ describeWithShallowAndMount('trigger', mountingMethod => {
expect(stub).calledWith(123)
})
- it('does not fire on disabled elements', () => {
+ it('does not fire on valid disabled elements', () => {
const clickHandler = sandbox.stub()
- const TestComponent = {
- template: '',
+ const ButtonComponent = {
+ template: '',
props: ['clickHandler']
}
- const wrapper = mountingMethod(TestComponent, {
+ const buttonWrapper = mountingMethod(ButtonComponent, {
propsData: {
clickHandler
}
})
- wrapper.trigger('click')
+ buttonWrapper.trigger('click')
expect(clickHandler.called).to.equal(false)
+
+ const changeHandler = sandbox.stub()
+ const InputComponent = {
+ template: '',
+ props: ['changeHandler']
+ }
+ const inputWrapper = mountingMethod(InputComponent, {
+ propsData: {
+ changeHandler
+ }
+ })
+ inputWrapper.trigger('change')
+ expect(changeHandler.called).to.equal(false)
+ })
+
+ it('fires on invalid disabled elements', () => {
+ const clickHandler = sandbox.stub()
+ const LinkComponent = {
+ template: 'Link',
+ props: ['clickHandler']
+ }
+ const linkWrapper = mountingMethod(LinkComponent, {
+ propsData: {
+ clickHandler
+ }
+ })
+ linkWrapper.trigger('click')
+ expect(clickHandler.called).to.equal(true)
})
it('handles .prevent', () => {