From bf004bb63bcc9e2ea5f9417461ecb3042b27a2fa Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 12:13:14 -0500 Subject: 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 --- dom/base/CustomElementRegistry.cpp | 119 +++++++++++++++++++-- dom/base/CustomElementRegistry.h | 16 ++- dom/base/Element.cpp | 75 +++++++------ dom/base/nsContentUtils.cpp | 22 ++++ dom/base/nsContentUtils.h | 5 + dom/tests/mochitest/webcomponents/mochitest.ini | 3 + .../custom-elements/CustomElementRegistry.html.ini | 12 --- .../HTMLElement-constructor.html.ini | 11 ++ .../attribute-changed-callback.html.ini | 16 --- .../htmlconstructor/newtarget.html.ini | 14 +++ 10 files changed, 222 insertions(+), 71 deletions(-) create mode 100644 testing/web-platform/meta/custom-elements/HTMLElement-constructor.html.ini create mode 100644 testing/web-platform/meta/custom-elements/htmlconstructor/newtarget.html.ini diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index cc6264b03..34ad9549d 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -434,8 +434,27 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition) { + RefPtr elementData = aCustomElement->GetCustomElementData(); + MOZ_ASSERT(elementData, "CustomElementData should exist"); + + // Let DEFINITION be ELEMENT's definition + CustomElementDefinition* definition = aDefinition; + if (!definition) { + mozilla::dom::NodeInfo* info = aCustomElement->NodeInfo(); + + // Make sure we get the correct definition in case the element + // is a extended custom element e.g.