Web Components

Short description: Software

Web Components are a set of features that provide a standard component model for the web[1] allowing for encapsulation and interoperability of individual HTML elements. Web Components are popular approach to build microfrontends.

Primary technologies used to create Web Components include:[2]

Custom Elements
APIs to define new HTML elements
Shadow DOM
encapsulated DOM and styling, with composition
HTML Templates
HTML fragments that are not rendered, but stored until instantiated via JavaScript[3]

## Contents

* 1 Features
* 1.1 Custom Elements
* 1.2 Shadow DOM
* 1.3 HTML Template
* 2 Browser support
* 3 Libraries
* 4 Community
* 5 History
* 6 See also
* 7 References
* 8 External links

## Features

### Custom Elements

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.[4]

### Shadow DOM

The Shadow DOM is a functionality that allows the web browser to render DOM elements without putting them into the main document DOM tree. This creates a barrier between what the developer and the browser can reach; 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 impact of CSS scoped within the Shadow DOM of a particular element is that HTML elements can be encapsulated without the risk of CSS styles leaking and affecting elements that they were not supposed to affect. Although these elements are encapsulated with regard to HTML and CSS, they can still fire events that can be picked up by other elements in the document.[5][6]

The scoped subtree in an element is called a shadow tree. The element the shadow tree is attached to is called a shadow host.[6]

A Shadow DOM must always be connected to an existing element, either through attaching it as a literal element or through scripting. In JavaScript, Shadow DOMs are attached to an element using `Element.attachShadow()`.[7]

### HTML Template

A HTML template is a way to insert chunks of HTML that are cloned from the template at will. The syntax of HTML templates looks like this:

<html>
<template>
<h1><slot name="title"></slot></h1>
<p><slot name="description"></slot></p>
</template>
</html>

Scripts will not run, and resources that are inside a template will not be fetched until the template is instantiated.[8]

## Browser support

Web Components are supported by current versions of all major browsers.[9]

Backward compatibility with older browsers is implemented using JavaScript-based polyfills.

## Libraries

There are many libraries that are built on Web Components with the aim of increasing the level of abstraction when creating custom elements. Some of these libraries are X-Tag, Slim.js, Polymer, Bosonic, Riot.js, Salesforce Lightning Web Components, DataFormsJS and Telepathy

## Community

There are numerous community efforts for the Web Components ecosystem. WebComponents.org[10] provides an interface to search for any existing Web Components, Custom Elements Everywhere[11] validates whether popular front-end frameworks are compatible and ready to use Web Components standard, with a set of pending bugs and available workarounds. Moreover, Vaadin Tutorials[12] has a dedicated section that shows how those workarounds are used efficiently with example demo apps and similarly related topics.

## History

In 2011, Web Components were introduced for the first time by Alex Russell at Fronteers Conference.[13]

In 2013, Polymer, a library based on Web Components was released by Google.[14] Polymer is canonical implementation of Material Design for web application user interfaces.

In 2016, RequireJS was introduced as JavaScript library and AMD loader plugin for custom elements.[15]

In 2017, Ionic (mobile app framework) team built StencilJS, a JavaScript compiler that generates Web Components.[16]

In 2018, Angular 6 introduced Angular Elements that lets you package your Angular components as custom web elements, which are part of the web components set of web platform APIs.[17]

In 2018, Firefox 63 enabled Web Components support by default and updated the developer tools to support them.[18]

In 2018, LitElement was developed by the Google Chrome team as part of larger Polymer project. LitElement was designed to be a lightweight and easy-to-use framework for creating web components.

## See also

* HTML Components
* Web framework
* Web resource

## References

1. ↑ GitHub - w3c/webcomponents: Web Components specifications., World Wide Web Consortium, 2019-01-03, https://github.com/w3c/webcomponents, retrieved 2019-01-03
2. ↑ "Web Components". https://developer.mozilla.org/en-US/docs/Web/Web_Components.
3. ↑ "<template>: The Content Template element". Mozilla. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template.
4. ↑ "Custom Elements". https://www.w3.org/TR/custom-elements/.
5. ↑ "What the Heck is Shadow DOM?". 2011-01-15. https://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/.
6. ↑ 6.0 6.1 "Shadow DOM v1: Self-Contained Web Components | Web | Google Developers". https://developers.google.com/web/fundamentals/getting-started/primers/shadowdom.
7. ↑ "Shadow DOM". https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM.
8. ↑ Community. "Introduction to the template elements — WebComponents.org". http://webcomponents.org/articles/introduction-to-template-element/.
9. ↑ "webcomponents.org - Discuss & share web components" (in en-us). https://www.webcomponents.org/.
10. ↑ "Search available Web Components". https://www.webcomponents.org/search.
11. ↑ "Validate Front-end Frameworks with Web Components Standard". https://custom-elements-everywhere.com.
12. ↑ "Web Components Tutorials". https://vaadin.com/learn/tutorials?query=web components.
13. ↑ "Web Components and Model Driven Views by Alex Russell · Fronteers". https://fronteers.nl/congres/2011/sessions/web-components-and-model-driven-views-alex-russell.
14. ↑ "The state of Web Components ★ Mozilla Hacks – the Web developer blog". https://hacks.mozilla.org/2015/06/the-state-of-web-components/.
15. ↑ "RequireJS in Commerce". https://developer.adobe.com/commerce/frontend-core/javascript/requirejs/.
16. ↑ "Web Component Solutions: A Comparison". https://levelup.gitconnected.com/web-component-solutions-a-comparison-e2fa25c34730.
17. ↑ "How to create Angular 6 Custom Elements and Web Components". https://www.freecodecamp.org/news/how-to-create-angular-6-custom-elements-web-components-c88814dc6e0a/.
18. ↑ "Developer Tools support for Web Components in Firefox 63". https://blog.nightly.mozilla.org/2018/09/06/developer-tools-support-for-web-components-in-firefox-63/.

## External links

*     * on GitHub
* Web Components Specifications WICG
* on GitHub WICG specifications
* Web Components at MDN Web Docs
* Browser Support for Custom Elements at Can I Use?
* Custom Elements Everywhere - Framework Support for Custom Elements
* Open Web Components
* What are Web Components?
* twoBirds

* v
* t
* e

World Wide Web Consortium (W3C)

Products and
standards|

| Recommendations|

* ActivityPub
* ARIA
* Canonical XML
* CDF
* CSS
* DOM
* Geolocation API
* HTML (HTML5)
* ITS
* JSON-LD
* Linked Data Notifications
* MathML
* Micropub
* OWL
* PLS
* RDF
* RDF Schema
* SISR
* SKOS
* SMIL
* SOAP
* SRGS
* SRI
* SSML
* SVG
* SCXML
* SHACL
* SPARQL
* Timed text
* VoiceXML
* Web storage
* WSDL
* Webmention
* WebSub
* XForms
* XHTML
* XHTML+RDFa
* XInclude
* XLink
* XML
* XML Base
* XML Encryption
* XML Events
* XML Information Set
* XML namespace
* XML Schema
* XML Signature
* XOP
* XPath
* XPath 2.0
* XPointer
* XProc
* XQuery
* XSL
* XSL-FO
* XSLT (elements)

|

Notes|

* IndieAuth
* JF2
* Post Type Discovery
* XAdES
* XHTML+SMIL
* XUP

Working drafts|

* CCXML
* CURIE
* EME
* InkML
* MSE
* RIF
* SMIL Timesheets
* sXBL
* XFDL
* XFrames
* XBL
* XMLHttpRequest

Guidelines|

* Web Content Accessibility Guidelines

Initiative|

* Multimodal Interaction Activity (MMI)
* Markup Validation Service
* Web Accessibility Initiative
* WebPlatform

Deprecated|

* C-HTML
* HDML
* JSSS
* PGML
* VML
* XHTML+MathML+SVG

Obsoleted|

* P3P

Organizations|

* Advisory Committee (AC)
* World Wide Web Foundation

Elected groups|

* Advisory Board (AB)

Working groups|

* CSS
* Geolocation
* Social Web
* SVG
* Web Hypertext Application Technology (WHATWG)
* Web Platform

Community groups|

* Web Incubator Community Group (WICG)

Closed groups|

* Device Description (DDWG)
* HTML

Software|

* CERN httpd
* Libwww

Browsers|

* Line Mode (1990–)
* Arena (1993–98)
* Agora (1994–97)
* Argo (1994–97)
* Amaya (browser/editor, 1996–2012)

Conferences|

* International World Wide Web Conference (IW3C)
* Steering Committee (IW3C2)
* First conference ("WWW1", 1994)

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Web Components. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Web_Components&oldid=245576"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template