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); |
} |