--- title: Element.openOrClosedShadowRoot slug: Web/API/Element/openOrClosedShadowRoot translation_of: Web/API/Element/openOrClosedShadowRoot ---
{{APIRef("Shadow DOM")}}{{Draft}}{{non-standard_header}}
Note: This API is available only to WebExtensions.

Element.openOrCloseShadowRoot 是一个只读属性。represents the shadow root hosted by the element, regardless if its {{DOMxRef("ShadowRoot.mode", "mode")}} is open or closed. Use {{DOMxRef("Element.attachShadow()")}} to add a shadow root to an existing element.

Syntax

var shadowroot = element.shadowRoot;

Value

A {{DOMxRef("ShadowRoot")}} object instance, regardless if its {{DOMxRef("ShadowRoot.mode", "mode")}} is set to open or closed, or null if no shadow root is present. (See {{DOMxRef("Element.attachShadow()")}} for further details).

Specifications

This property is not part of any specification.

Browser compatibility

{{Compat("api.Element.openOrClosedShadowRoot")}}

See also