diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 07:05:27 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 07:05:27 -0400 |
commit | 3a74795a56e92313c1b33a54500917794ba09b72 (patch) | |
tree | 949f2d97d27713e6a8960b948e51644bcaf27c02 /dom/base/Element.cpp | |
parent | 873abc7bcb6adc5cbf98ba3e1bd9a3271afc9806 (diff) | |
download | uxp-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.cpp | 19 |
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) |