Index: third_party/WebKit/Source/core/dom/Element.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp |
index 2641196365dc0a6bc82318e49ddac52a4689f373..216f4d331bb68a070891c4864171731a2ca564f6 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -1902,10 +1902,15 @@ CustomElementDefinition* Element::customElementDefinition() const |
PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(const ScriptState* scriptState, ExceptionState& exceptionState) |
{ |
OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsingFeatures::Feature::ElementCreateShadowRoot); |
- ShadowRoot* root = shadowRoot(); |
- if (root && (root->type() == ShadowRootType::Open || root->type() == ShadowRootType::Closed)) { |
- exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts this type of shadow tree."); |
- return nullptr; |
+ if (ShadowRoot* root = shadowRoot()) { |
+ if (root->isV1()) { |
+ exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a v1 shadow tree."); |
+ return nullptr; |
+ } |
+ if (root->type() == ShadowRootType::UserAgent) { |
+ exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts an user-agent shadow tree."); |
+ return nullptr; |
+ } |
} |
return createShadowRootInternal(ShadowRootType::V0, exceptionState); |
} |