Web Components

Web Components

Web Components consist of three elemens:

Custom Elements

Usage

Shadow DOM

Makes encapsulation possible, but not necessary.

Keeps the markup structure, style, and behavior hidden and separate from other code on the page so that different parts do not clash, and the code can be kept nice and clean.

Attention!!! Outside styles will not work

Two modes:

  1. open - accessable from js
  2. closed - not accessable from js

Append children:

Standard elements as Video use the Shadow DOM for example.

Without Shadow DOM

HTML Templates and Slots

Full Example

Read more

Web Components