Commit 07d811aa authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

Remove inDocument check for emitting change events

The html spec does not seem to say anything against emitting change
events for input elements which are detached from the DOM. It does say
that immutable input elements should not have change events emitted for
them, but I don't think that having it detached from the DOM means that
it is immutable, especially since we can successfully change the
.checked value while detached from the dom.

Bug: 773680
Change-Id: Ie579ed1f3c34fc03f74554a5685f40c510805f2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885093Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710642}
parent cba851a9
...@@ -963,13 +963,12 @@ bool HTMLInputElement::HasBeenPasswordField() const { ...@@ -963,13 +963,12 @@ bool HTMLInputElement::HasBeenPasswordField() const {
} }
void HTMLInputElement::DispatchChangeEventIfNeeded() { void HTMLInputElement::DispatchChangeEventIfNeeded() {
if (isConnected() && input_type_->ShouldSendChangeEventAfterCheckedChanged()) if (input_type_->ShouldSendChangeEventAfterCheckedChanged())
DispatchChangeEvent(); DispatchChangeEvent();
} }
void HTMLInputElement::DispatchInputAndChangeEventIfNeeded() { void HTMLInputElement::DispatchInputAndChangeEventIfNeeded() {
if (isConnected() && if (input_type_->ShouldSendChangeEventAfterCheckedChanged()) {
input_type_->ShouldSendChangeEventAfterCheckedChanged()) {
DispatchInputEvent(); DispatchInputEvent();
DispatchChangeEvent(); DispatchChangeEvent();
} }
......
<!DOCTYPE html>
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
const input = document.createElement('input');
input.type = 'checkbox';
input.addEventListener('change', t.step_func_done(() => {}));
input.dispatchEvent(new MouseEvent('click'));
}, 'This test will pass if <input type=checkbox> emits change events while detached from document.body');
</script>
<!DOCTYPE html>
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
const input = document.createElement('input');
input.type = 'radio';
input.addEventListener('change', t.step_func_done(() => {}));
input.dispatchEvent(new MouseEvent('click'));
}, 'This test will pass if <input type=radio> emits change events while detached from document.body');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment