Introduction Of Web Components | Web Components | Amit Padhiyar (Saatody)
Web Components are set of features or suite of different technologies that allowing to create, encapsulation and interoperability of reusable HTML custom elements. There are main three technologies to create Web Components.
- Custom Elements
- Shadow DOM
- HTML Templates
Custom Elements
- A set of JavaScript APIs that allow you to define custom elements and their behaviour.
- There are two parts to Custom Elements: autonomous custom elements and customized built-in elements.
- Autonomous custom elements are HTML elements that are entirely separated from native HTML elements; they are essentially built from the bottom up using the Custom Elements API.
- Customized built-in elements are elements that are built upon native HTML elements to reuse their functionality.
Shadow DOM
- A set of JavaScript APIs for attaching an encapsulated "shadow" DOM tree to an element.
- And shadow DOM is a functionality that allows the web browser to render DOM elements without putting them into the main document DOM tree.
- Or it is rendered separately from the main document DOM and controlling associated functionality.
- In this way, you can keep an element's features private, so they can be scripted and styled without the fear of collision with other parts of the document.
- The developer cannot access the Shadow DOM in the same way they would with nested elements, while the browser can render and modify that code the same way it would with nested elements.
- The scoped subtree in an element is called a shadow tree. The element the shadow tree is attached to is called a shadow host.
HTML Templates
- The <template> and <slot> elements enable you to write markup templates that are not displayed in the rendered page. These can then be reused multiple times as the basis of a custom element's structure.
- HTML Templates are supported in Google Chrome, Mozilla Firefox, Microsoft Edge, Safari, and Opera.
Comments
Post a Comment