Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElement.cpp

Issue 2166213002: Fire attributeChangedCallback on style changes for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dominicc review Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
index 16d712fb87c71b60087305551540950dc4e5efc6..1156806d5fd6dde1670b8356dbed13ad4effb619 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
@@ -32,13 +32,21 @@ CustomElementsRegistry* CustomElement::registry(const Document& document)
return nullptr;
}
-CustomElementDefinition* CustomElement::definitionForElement(const Element& element)
+static CustomElementDefinition* definitionForElementWithoutCheck(const Element& element)
{
+ DCHECK_EQ(element.getCustomElementState(), CustomElementState::Custom);
if (CustomElementsRegistry* registry = CustomElement::registry(element))
return registry->definitionForName(element.localName());
return nullptr;
}
+CustomElementDefinition* CustomElement::definitionForElement(const Element* element)
+{
+ if (!element || element->getCustomElementState() != CustomElementState::Custom)
+ return nullptr;
+ return definitionForElementWithoutCheck(*element);
+}
+
bool CustomElement::isValidName(const AtomicString& name)
{
if (!name.length() || name[0] < 'a' || name[0] > 'z')
@@ -180,16 +188,14 @@ void CustomElement::enqueue(Element* element, CustomElementReaction* reaction)
void CustomElement::enqueueConnectedCallback(Element* element)
{
- DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom);
- CustomElementDefinition* definition = definitionForElement(*element);
+ CustomElementDefinition* definition = definitionForElementWithoutCheck(*element);
if (definition->hasConnectedCallback())
definition->enqueueConnectedCallback(element);
}
void CustomElement::enqueueDisconnectedCallback(Element* element)
{
- DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom);
- CustomElementDefinition* definition = definitionForElement(*element);
+ CustomElementDefinition* definition = definitionForElementWithoutCheck(*element);
if (definition->hasDisconnectedCallback())
definition->enqueueDisconnectedCallback(element);
}
@@ -199,8 +205,7 @@ void CustomElement::enqueueAttributeChangedCallback(Element* element,
const QualifiedName& name,
const AtomicString& oldValue, const AtomicString& newValue)
{
- DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom);
- CustomElementDefinition* definition = definitionForElement(*element);
+ CustomElementDefinition* definition = definitionForElementWithoutCheck(*element);
if (definition->hasAttributeChangedCallback(name))
definition->enqueueAttributeChangedCallback(element, name, oldValue, newValue);
}

Powered by Google App Engine
This is Rietveld 408576698