fix(dom/base/Element): Clear focus when tabIndex is unset from the active element
draft
fix(dom/base/Element): Clear focus when tabIndex is unset from the active element
Fixes a failing Web Platform Test (https://github.com/w3c/web-platform-tests/blob/009111410a1099e85d4027a679985975757ceb4d/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html#L86).
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -3039,16 +3039,24 @@ Element::UnsetAttr(int32_t aNameSpaceID,
}
nsAttrValue oldValue;
rv = mAttrsAndChildren.RemoveAttrAt(index, oldValue);
NS_ENSURE_SUCCESS(rv, rv);
PostIdMaybeChange(aNameSpaceID, aName, nullptr);
+ if (aName == nsGkAtoms::tabindex) {
+ nsFocusManager *fm = nsFocusManager::GetFocusManager();
+
+ if (fm && fm->IsFocused(this)) {
+ fm->ClearFocus(OwnerDoc()->GetWindow());
+ }
+ }
+
if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) {
RefPtr<nsXBLBinding> binding = GetXBLBinding();
if (binding) {
binding->AttributeChanged(aName, aNameSpaceID, true, aNotify);
}
}
if (CustomElementRegistry::IsCustomElementEnabled()) {