diff options
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) |