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

Allow mutating <input disabled type=checkbox/radio> #27666

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 10 additions & 7 deletions components/script/dom/htmlinputelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2728,18 +2728,18 @@ impl Activatable for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#reset-button-state-%28type=reset%29:activation-behaviour-2
// https://html.spec.whatwg.org/multipage/#checkbox-state-%28type=checkbox%29:activation-behaviour-2
// https://html.spec.whatwg.org/multipage/#radio-button-state-%28type=radio%29:activation-behaviour-2
InputType::Submit |
InputType::Reset |
InputType::File |
InputType::Checkbox |
InputType::Radio => self.is_mutable(),
InputType::Submit | InputType::Reset | InputType::File => self.is_mutable(),
InputType::Checkbox | InputType::Radio => true,
_ => false,
}
}

// https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior
fn legacy_pre_activation_behavior(&self) -> Option<InputActivationState> {
if !self.is_mutable() {
if !self.is_mutable() &&
self.input_type() != InputType::Checkbox &&
self.input_type() != InputType::Radio
{
Copy link
Member

Choose a reason for hiding this comment

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

Based on https://html.spec.whatwg.org/multipage/input.html#the-input-element:legacy-pre-activation-behavior it looks like this entire check can be removed instead.

return None;
}

Expand Down Expand Up @@ -2777,7 +2777,10 @@ impl Activatable for HTMLInputElement {
// https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior
fn legacy_canceled_activation_behavior(&self, cache: Option<InputActivationState>) {
// Step 1
if !self.is_mutable() {
if !self.is_mutable() &&
self.input_type() != InputType::Checkbox &&
self.input_type() != InputType::Radio
{
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this check as well.

return;
}
let ty = self.input_type();
Expand Down
13 changes: 0 additions & 13 deletions tests/wpt/metadata/dom/events/Event-dispatch-click.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,3 @@
type: testharness
[event state during post-click handling]
expected: FAIL

[disabled radio should be checked from dispatchEvent(new MouseEvent("click"))]
expected: FAIL

[disabled checkbox should be checked from dispatchEvent(new MouseEvent("click"))]
expected: FAIL

[disabled radio should get legacy-canceled-activation behavior]
expected: FAIL

[disabled checkbox should get legacy-canceled-activation behavior]
expected: FAIL