Web Components
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
Web Components are a set of features that provide a standard component model for the web
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]
Features
Custom Elements
There are two parts to Custom Elements: autonomous custom elements and customized built-in elements. Autonomous custom elements are
Shadow DOM
The Shadow DOM is a functionality that allows the
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
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, Telepathy, and Wompo
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 aka Infinite Craft
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,
See also
References
- ^ GitHub - w3c/webcomponents: Web Components specifications., World Wide Web Consortium, 2019-01-03, retrieved 2019-01-03
- ^ "Web Components". MDN Web Docs. Retrieved 2019-01-03.
- ^ "<template>: The Content Template element". MDN Web Docs. Mozilla. Retrieved 2018-07-08.
- ^ "Custom Elements". www.w3.org. Retrieved 2016-12-01.
- ^ "What the Heck is Shadow DOM?". Dimitri Glazkov. 2011-01-15. Retrieved 2016-12-01.
- ^ a b "Shadow DOM v1: Self-Contained Web Components | Web | Google Developers". Google Developers. Retrieved 2016-12-01.
- ^ "Shadow DOM". Mozilla Developer Network. Retrieved 2016-12-01.
- ^ Community. "Introduction to the template elements — WebComponents.org". webcomponents.org. Retrieved 2016-12-03.
- ^ "webcomponents.org - Discuss & share web components". www.webcomponents.org. Retrieved 2020-07-22.
- ^ "Search available Web Components".
- ^ "Validate Front-end Frameworks with Web Components Standard".
- ^ "Web Components Tutorials".
- ^ "Web Components and Model Driven Views by Alex Russell · Fronteers". fronteers.nl. Retrieved 2016-12-02.
- ^ "The state of Web Components ★ Mozilla Hacks – the Web developer blog". hacks.mozilla.org. Retrieved 2016-12-02.
- ^ "RequireJS in Commerce".
- ^ "Web Component Solutions: A Comparison".
- ^ "How to create Angular 6 Custom Elements and Web Components".
- ^ "Developer Tools support for Web Components in Firefox 63".