Bug 1833570 - Correct the handling of popovertargetaction value. r=emilio

The popovertargetaction attribute's invalid value default and missing value default are both the toggle state.

https://html.spec.whatwg.org/#popover-target-attribute-activation-behavior

Differential Revision: https://phabricator.services.mozilla.com/D179050
This commit is contained in:
Ziran Sun
2023-06-05 12:30:10 +00:00
parent 721dba2d67
commit a8187d4437
4 changed files with 5 additions and 34 deletions

View File

@@ -2881,12 +2881,13 @@ void nsGenericHTMLFormControlElementWithState::HandlePopoverTargetAction() {
return;
}
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::popovertargetaction);
if (!value) {
return;
auto action = PopoverTargetAction::Toggle;
if (const nsAttrValue* value =
GetParsedAttr(nsGkAtoms::popovertargetaction)) {
MOZ_ASSERT(value->Type() == nsAttrValue::eEnum);
action = static_cast<PopoverTargetAction>(value->GetEnumValue());
}
auto action = static_cast<PopoverTargetAction>(value->GetEnumValue());
bool canHide = action == PopoverTargetAction::Hide ||
action == PopoverTargetAction::Toggle;
bool canShow = action == PopoverTargetAction::Show ||