Bug 1334051 - Part 2: Invoke attributeChangedCallback only if attribute name is in the observed attribute list.

We call attributeChangedCallback in two cases:

1. When any of the attributes in the observed attribute list has changed, appended, removed, or replaced.

2. When upgrading an element, for each attribute in element's attribute list that is in the observed attribute list.

Note: w/ Fixup for not implementing an API Enhancement Bug 1363481.

Tag UXP Issue #1344
This commit is contained in:
Gaming4JC 2020-01-05 12:13:14 -05:00 committed by Roy Tam
commit 2bd8be69ea
10 changed files with 222 additions and 71 deletions

View file

@ -9637,6 +9637,28 @@ nsContentUtils::SetupCustomElement(Element* aElement,
return registry->SetupCustomElement(aElement, aTypeExtension);
}
/* static */ CustomElementDefinition*
nsContentUtils::GetElementDefinitionIfObservingAttr(Element* aCustomElement,
nsIAtom* aExtensionType,
nsIAtom* aAttrName)
{
nsString extType = nsDependentAtomString(aExtensionType);
NodeInfo *ni = aCustomElement->NodeInfo();
CustomElementDefinition* definition =
LookupCustomElementDefinition(aCustomElement->OwnerDoc(), ni->LocalName(),
ni->NamespaceID(),
extType.IsEmpty() ? nullptr : &extType);
// Custom element not defined yet or attribute is not in the observed
// attribute list.
if (!definition || !definition->IsInObservedAttributeList(aAttrName)) {
return nullptr;
}
return definition;
}
/* static */ void
nsContentUtils::EnqueueLifecycleCallback(nsIDocument* aDoc,
nsIDocument::ElementCallbackType aType,