Index: third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp |
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp |
index bf8acd6fe36eabce44f76102a7394b91cb2ee86e..6db283ccd58a7a75331003f4d3758c0d2120d1d9 100644 |
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp |
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp |
@@ -4,7 +4,6 @@ |
#include "core/dom/custom/CustomElementDefinition.h" |
-#include "core/dom/Attr.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/dom/custom/CEReactionsScope.h" |
#include "core/dom/custom/CustomElement.h" |
@@ -19,14 +18,6 @@ |
CustomElementDefinition::CustomElementDefinition( |
const CustomElementDescriptor& descriptor) |
: m_descriptor(descriptor) |
-{ |
-} |
- |
-CustomElementDefinition::CustomElementDefinition( |
- const CustomElementDescriptor& descriptor, |
- const HashSet<AtomicString>& observedAttributes) |
- : m_observedAttributes(observedAttributes) |
- , m_descriptor(descriptor) |
{ |
} |
@@ -102,8 +93,14 @@ |
// https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an-element |
void CustomElementDefinition::upgrade(Element* element) |
{ |
- if (!m_observedAttributes.isEmpty()) |
- enqueueAttributeChangedCallbackForAllAttributes(element); |
+ // TODO(kojii): This should be reversed by exposing observedAttributes from |
+ // ScriptCustomElementDefinition, because Element::attributes() requires |
+ // attribute synchronizations, and generally elements have more attributes |
+ // than custom elements observe. |
+ for (const auto& attribute : element->attributes()) { |
+ if (hasAttributeChangedCallback(attribute.name())) |
+ enqueueAttributeChangedCallback(element, attribute.name(), nullAtom, attribute.value()); |
+ } |
if (element->inShadowIncludingDocument() && hasConnectedCallback()) |
enqueueConnectedCallback(element); |
@@ -123,12 +120,6 @@ |
return; |
CHECK(element->getCustomElementState() == CustomElementState::Custom); |
-} |
- |
-bool CustomElementDefinition::hasAttributeChangedCallback( |
- const QualifiedName& name) |
-{ |
- return m_observedAttributes.contains(name.localName()); |
} |
static void enqueueReaction(Element* element, CustomElementReaction* reaction) |
@@ -161,20 +152,4 @@ |
enqueueReaction(element, new CustomElementAttributeChangedCallbackReaction(this, name, oldValue, newValue)); |
} |
-void CustomElementDefinition::enqueueAttributeChangedCallbackForAllAttributes( |
- Element* element) |
-{ |
- // Avoid synchronizing all attributes unless it is needed, while enqueing |
- // callbacks "in order" as defined in the spec. |
- // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an-element |
- for (const AtomicString& name : m_observedAttributes) |
- element->synchronizeAttribute(name); |
- for (const auto& attribute : element->attributesWithoutUpdate()) { |
- if (hasAttributeChangedCallback(attribute.name())) { |
- enqueueAttributeChangedCallback(element, attribute.name(), |
- nullAtom, attribute.value()); |
- } |
- } |
-} |
- |
} // namespace blink |