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 282fa462f1cec75149c5b5725d8acbb0f682adb5..736513fb7040e1cdb7afa26a6f588a634de3e694 100644 |
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
@@ -24,10 +24,13 @@ CustomElementsRegistry* CustomElement::registry(const Element& element) |
{ |
return registry(element.document()); |
} |
+ |
CustomElementsRegistry* CustomElement::registry(const Document& document) |
{ |
- if (LocalDOMWindow* window = document.domWindow()) |
- return window->customElements(); |
+ if (Document* contextDocument = const_cast<Document&>(document).contextDocument()) { |
+ if (LocalDOMWindow* window = contextDocument->domWindow()) |
+ return window->customElements(); |
+ } |
return nullptr; |
} |
@@ -81,6 +84,7 @@ bool CustomElement::isValidName(const AtomicString& name) |
bool CustomElement::shouldCreateCustomElement(Document& document, const AtomicString& localName) |
{ |
return RuntimeEnabledFeatures::customElementsV1Enabled() |
+ && document.contextDocument() && document.contextDocument()->frame() |
&& isValidName(localName); |
} |