fix(dom/base/Element): Clear focus when tabIndex is unset from the active element draft
authorSorin Davidoi <sorin.davidoi@gmail.com>
Sat, 10 Feb 2018 14:31:58 +0100
changeset 753526 fb9094180e32a9587b8e5b426f634e5ae36e560f
parent 753525 dcb46b7aec0e411ede741bc0c619d581b1c3a0ca
child 753527 97014921a26abe9f60d39289f16a3af7249305ab
push id98577
push userbmo:sorin.davidoi@gmail.com
push dateSat, 10 Feb 2018 13:40:06 +0000
milestone60.0a1
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).
dom/base/Element.cpp
--- 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()) {