summaryrefslogtreecommitdiff
path: root/dom/base/Element.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:05:27 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:05:27 -0400
commit3a74795a56e92313c1b33a54500917794ba09b72 (patch)
tree949f2d97d27713e6a8960b948e51644bcaf27c02 /dom/base/Element.cpp
parent873abc7bcb6adc5cbf98ba3e1bd9a3271afc9806 (diff)
downloaduxp-3a74795a56e92313c1b33a54500917794ba09b72.tar.gz
Bug 1411878 - Support Element.shadowRoot and Element.assignedSlot / TextNode.assignedSlot on closed shadow root
Tag #1375
Diffstat (limited to 'dom/base/Element.cpp')
-rw-r--r--dom/base/Element.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index 638d6674d2..cd803a60f9 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1104,6 +1104,25 @@ Element::GetSlot(nsAString& aName)
GetAttr(kNameSpaceID_None, nsGkAtoms::slot, aName);
}
+// https://dom.spec.whatwg.org/#dom-element-shadowroot
+ShadowRoot*
+Element::GetShadowRootByMode() const
+{
+ /**
+ * 1. Let shadow be context object’s shadow root.
+ * 2. If shadow is null or its mode is "closed", then return null.
+ */
+ ShadowRoot* shadowRoot = GetShadowRoot();
+ if (!shadowRoot || shadowRoot->IsClosed()) {
+ return nullptr;
+ }
+
+ /**
+ * 3. Return shadow.
+ */
+ return shadowRoot;
+}
+
// https://dom.spec.whatwg.org/#dom-element-attachshadow
already_AddRefed<ShadowRoot>
Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)