A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/shadowRoot below:

ElementInternals: shadowRoot property - Web APIs

ElementInternals: shadowRoot property

The shadowRoot read-only property of the ElementInternals interface returns the ShadowRoot for this element.

Value

A ShadowRoot if the element has a shadow root, otherwise null.

Examples

The following example prints the value of shadowRoot to the console, immediately after calling HTMLElement.attachInternals(). At this point the value is null. After calling Element.attachShadow() the element has a Shadow Root, and shadowRoot returns the object representing it.

class MyCustomElement extends HTMLElement {
  constructor() {
    super();
    this.internals_ = this.attachInternals();

    console.log(this.internals_.shadowRoot); // null

    this.attachShadow({ mode: "open" });

    console.log(this.internals_.shadowRoot); // a ShadowRoot object
  }
}
Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3