Skip to content

Commit

Permalink
Fix radio/checkbox to not fire events when disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Mar 28, 2021
1 parent 761d8cc commit fdf97d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/jsdom/living/nodes/HTMLInputElement-impl.js
Expand Up @@ -196,8 +196,10 @@ class HTMLInputElementImpl extends HTMLElementImpl {
const { form } = this;

if (this.type === "checkbox" || (this.type === "radio" && !this._preCheckedRadioState)) {
fireAnEvent("input", this, undefined, { bubbles: true });
fireAnEvent("change", this, undefined, { bubbles: true });
if (this.isConnected) {
fireAnEvent("input", this, undefined, { bubbles: true });
fireAnEvent("change", this, undefined, { bubbles: true });
}
} else if (form && this.type === "submit") {
form._doSubmit();
} else if (form && this.type === "reset") {
Expand Down
3 changes: 0 additions & 3 deletions test/web-platform-tests/to-run.yaml
Expand Up @@ -165,9 +165,6 @@ DIR: dom/events

AddEventListenerOptions-signal.any.html: [fail, Not implemented]
Event-dispatch-click.tentative.html: [fail, Test is wrong, https://github.com/web-platform-tests/wpt/issues/27819]
Event-dispatch-detached-input-and-change.html: [fail,
Need implement connected and use it in https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/nodes/HTMLInputElement-impl.js#L199
See https://html.spec.whatwg.org/multipage/input.html#checkbox-state-(type=checkbox)]
Event-isTrusted.any.html: [fail, Unknown]
Event-timestamp-high-resolution.html: [fail, Not implemented]
EventListener-incumbent-global-1.sub.html: [timeout, Multi-globals]
Expand Down

0 comments on commit fdf97d8

Please sign in to comment.