Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatching click event executes click handler for disabled elements #2665

Closed
eps1lon opened this issue Sep 17, 2019 · 1 comment
Closed

Comments

@eps1lon
Copy link
Contributor

eps1lon commented Sep 17, 2019

Basic info:

  • Node.js version: 10.16.3
  • jsdom version: 15.1.1

Minimal reproduction case

const { JSDOM } = require("jsdom");

const { window } = new JSDOM(`
<!DOCTYPE html>
<html>
  <body><button disabled></button></body>
</html>
`);

const button = window.document.querySelector('button');
button.addEventListener('click', () => console.log('click'));

button.click();
button.dispatchEvent(new window.MouseEvent('click'))

https://runkit.com/eps1lon/5d80dae1e7cc46001351ca95

How does similar code behave in browsers?

https://jsbin.com/kebukirute/edit?html,js,console

In the browser no click handler is called. In JSDOM the click handler is called on dispatchEvent but not click().

@domenic
Copy link
Member

domenic commented Oct 14, 2019

jsdom matches the spec and Firefox here. Blink and WebKit do not match the spec.

The interop issue here is tracked in whatwg/html#2368, which may eventually lead to either fixing Blink and WebKit, or updating the spec to match them and then changing Firefox and jsdom. Until that gets done though, jsdom is behaving as intended, so I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants