Declarative shadow DOM

noun

say it: “dih-KLAIR-uh-tiv SHAD-oh DOM” /dɪˈklɛrətɪv ˈʃædoʊ dɑm/

A way to build a component's shadow root in plain HTML, with a template element that has a shadowrootmode attribute, so it works before any JavaScript runs.

What is Declarative shadow DOM?

Declarative shadow DOM — HTML syntax that creates a shadow root from a template element during parsing.

<article>
  <template shadowrootmode="open">
    <slot></slot>
  </template>
  Order ready
</article>

In a sentence

  • “I wrote the card's inner HTML in a template with shadowrootmode="open", which is declarative shadow DOM.”
  • “With declarative shadow DOM, the review card's layout showed up even with JavaScript turned off.”

Level: Freelancer · More JavaScript terms at this level

Updated