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
commit7a879d50ed9657c488b816f10eb734fff49fdb81 (patch)
tree949f2d97d27713e6a8960b948e51644bcaf27c02 /dom/base/Element.cpp
parentad74b1ce285012bdca847a5358317b1dde97cd9f (diff)
downloadaura-central-7a879d50ed9657c488b816f10eb734fff49fdb81.tar.gz
Bug 1411878 - Support Element.shadowRoot and Element.assignedSlot / TextNode.assignedSlot on closed shadow root
Tag mcp-graveyard/UXP%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 638d6674d..cd803a60f 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)