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

Unified Diff: Source/core/dom/Element.cpp

Issue 1223473004: Prohibit createShadowRoot({mode: 'open'}) on existing shadow root. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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
« no previous file with comments | « LayoutTests/fast/dom/shadow/create-shadow-root-with-parameter-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 85e3cac75909a1c28968bc646f0ac8497a31723a..f1636c5f76c05f3f2850626f0ddef7971be0aa33 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1828,10 +1828,17 @@ PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(const ScriptState*
UseCounter::count(document(), UseCounter::ElementCreateShadowRootWithParameter);
OriginsUsingFeatures::count(scriptState, document(), OriginsUsingFeatures::Feature::ElementCreateShadowRoot);
- // TODO(kochi): Add support for closed shadow root. crbug.com/459136
- if (shadowRootInitDict.hasMode() && shadowRootInitDict.mode() == "closed") {
- exceptionState.throwDOMException(NotSupportedError, "Closed shadow root is not implemented yet.");
- return nullptr;
+
+ if (shadowRootInitDict.hasMode()) {
+ if (shadowRoot()) {
+ exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a shadow tree.");
+ return nullptr;
+ }
+ // TODO(kochi): Add support for closed shadow root. crbug.com/459136
+ if (shadowRootInitDict.mode() == "closed") {
+ exceptionState.throwDOMException(NotSupportedError, "Closed shadow root is not implemented yet.");
+ return nullptr;
+ }
}
RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRoot(exceptionState);
« no previous file with comments | « LayoutTests/fast/dom/shadow/create-shadow-root-with-parameter-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698