--- title: Element.openOrClosedShadowRoot slug: Web/API/Element/openOrClosedShadowRoot translation_of: Web/API/Element/openOrClosedShadowRoot ---
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.
var shadowroot = element.shadowRoot;
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).
This property is not part of any specification.
{{Compat("api.Element.openOrClosedShadowRoot")}}