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

dispatchEvent now takes into account if an element has been disabled #2681

Conversation

brendo
Copy link
Contributor

@brendo brendo commented Oct 9, 2019

Fixes #2665

return;
}

return super.dispatchEvent(eventImpl);
Copy link
Member

@TimothyGu TimothyGu Oct 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute:concept-fe-disabled says:

A form control that is disabled must prevent any click events that are queued on the user interaction task source from being dispatched on the element.

So any special processing must only apply to click events. Edit: the event has to both have the name "click" as well as being a MouseEvent object, as click event is defined to be a MouseEvent.

Additionally, some places call _dispatch directly:

return tryImplForWrapper(target)._dispatch(event, legacyTargetOverrideFlag);
It might be better to override _dispatch instead of the more public dispatchEvent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can't be the right part of the spec, because the user interaction task source is never involved in jsdom, I don't think.

The click() disabled handling is in the spec at https://html.spec.whatwg.org/multipage/interaction.html#activation:concept-fe-disabled.

For dispatchEvent, I cannot find any support in the spec for this. Furthmore, running the test in #2665 in Firefox shows that it matches jsdom.

So I don't think we should change this in jsdom, but there is a spec interop issue, apparently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domenic
Copy link
Member

domenic commented Oct 14, 2019

Since jsdom is behaving according to the spec here, we won't change anything.

@brendo
Copy link
Contributor Author

brendo commented Oct 14, 2019

Thanks for the replies! I meant to come back to this but forget. I'm glad it kicked off some discussion though 👍

@brendo brendo deleted the feature_issue-2665-dispatch-event-on-disabled branch October 14, 2019 09:01
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 this pull request may close these issues.

dispatching click event executes click handler for disabled elements
3 participants