<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.whatwg.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dglazkov</id>
	<title>WHATWG Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.whatwg.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dglazkov"/>
	<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/wiki/Special:Contributions/Dglazkov"/>
	<updated>2026-05-23T06:35:14Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Elements&amp;diff=9820</id>
		<title>Custom Elements</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Elements&amp;diff=9820"/>
		<updated>2015-03-11T21:06:02Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents open technical issues with [https://w3c.github.io/webcomponents/spec/custom/ Custom Elements] based on [https://lists.w3.org/Archives/Public/public-webapps/2015JanMar/ public-webapps@w3.org from January to March 2015].&lt;br /&gt;
&lt;br /&gt;
== Rough consensus ==&lt;br /&gt;
&lt;br /&gt;
There appears to be rough consensus for:&lt;br /&gt;
&lt;br /&gt;
* ES6-style classes (Spec/Chrome: mutating prototype)&lt;br /&gt;
* Subclassing of HTMLElement and SVGElement&lt;br /&gt;
* An API to tie a class to a local name (e.g. &amp;lt;code&amp;gt;registerElement()&amp;lt;/code&amp;gt;)&lt;br /&gt;
* Lifecycle callbacks for: insertion into a document, removal from a document, mutation of an attribute&lt;br /&gt;
&lt;br /&gt;
== Additional lifecycle callbacks ==&lt;br /&gt;
&lt;br /&gt;
There&#039;s a proposal in various bugs to offer these lifecycle callbacks as well:&lt;br /&gt;
&lt;br /&gt;
* Adopting so when moving nodes across documents adjustments can be made (e.g. an &amp;lt;code&amp;gt;&amp;amp;lt;img&amp;gt;&amp;lt;/code&amp;gt; has its animation restarted). This callback needs to be passed the old and new document.&lt;br /&gt;
* Cloning so &amp;lt;code&amp;gt;cloneNode()&amp;lt;/code&amp;gt; can have similar semantics for custom elements as it does for e.g. &amp;lt;code&amp;gt;&amp;amp;lt;input&amp;gt;&amp;lt;/code&amp;gt;. For cloning we want the browser to create a clone (via the constructor) and copy all content attributes. Then the callback is passed the clone, a document, and the clone children flag (note that these are only needed for children not part of a tree, for elements such as &amp;lt;code&amp;gt;&amp;amp;lt;template&amp;gt;&amp;lt;/code&amp;gt;, children part of the tree are handled by the browser).&lt;br /&gt;
&lt;br /&gt;
== Use symbols to identify lifecycle callbacks ==&lt;br /&gt;
&lt;br /&gt;
It has been suggested that we should use symbols rather than names ending in &amp;lt;code&amp;gt;Callback&amp;lt;/code&amp;gt; to avoid collisions with libraries.&lt;br /&gt;
&lt;br /&gt;
== Upgrading ==&lt;br /&gt;
&lt;br /&gt;
Upgrading is the concept of going from a piece of markup, such as &amp;lt;code&amp;gt;&amp;amp;lt;my-div data-teehee=&amp;quot;💩&amp;quot;&amp;gt;&amp;amp;lt;/my-div&amp;gt;&amp;lt;/code&amp;gt;, to an object in a tree.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Tactic&lt;br /&gt;
! Explanation&lt;br /&gt;
! Drawbacks&lt;br /&gt;
|-&lt;br /&gt;
! Spec/Chrome&lt;br /&gt;
| A basic element is created by the parser and then its prototype is mutated at a later stage followed by a callback.&lt;br /&gt;
|&lt;br /&gt;
* Does not use ES6-style classes&lt;br /&gt;
* Does not have identity at all (at best it looks alike due to the mutated prototype)&lt;br /&gt;
|-&lt;br /&gt;
! Brain transplant ([https://lists.w3.org/Archives/Public/public-webapps/2015JanMar/0230.html &amp;quot;Dmitry&amp;quot;])&lt;br /&gt;
| A basic element is created by the parser and a callback registered by the developer is invoked at a later point to turn that basic element into a custom element.&lt;br /&gt;
|&lt;br /&gt;
* Not having identity at creation-time is currently a mismatch with the rest of the platform. (Domenic suggests we could maybe change the rest of the platform.)&lt;br /&gt;
|-&lt;br /&gt;
! Dummy replacement&lt;br /&gt;
| A dummy element is created by the parser and replaced at a later point by an actual instance of the custom element created by invoking the constructor registered by the developer.&lt;br /&gt;
|&lt;br /&gt;
* What about attributes on the dummy element?&lt;br /&gt;
* What about event listeners on the dummy element?&lt;br /&gt;
* What if the dummy element was removed from the tree (or moved around)?&lt;br /&gt;
* Causes mutation observer &amp;quot;spam&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Synchronous constructor&lt;br /&gt;
| The constructor registered by the developer is invoked by the parser at the point the custom element is created and inserted into the tree.&lt;br /&gt;
| &lt;br /&gt;
* Requires synchronization for document.write() for each custom element.&lt;br /&gt;
* Nested event loop.&lt;br /&gt;
* Does not work with asynchronously loaded assets.&lt;br /&gt;
* Unclear how it works with cloning.&lt;br /&gt;
|-&lt;br /&gt;
! Almost-synchronous constructor ([https://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0098.html &amp;quot;Jonas&amp;quot;])&lt;br /&gt;
| The parser does bookkeeping of where custom elements need to be inserted and does it at a later synchronization point.&lt;br /&gt;
|&lt;br /&gt;
* Potential performance issues.&lt;br /&gt;
* Complicated?&lt;br /&gt;
* Unclear how it works with cloning.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(Written under the assumption that mutating the prototype of the basic element is no longer considered viable.)&lt;br /&gt;
&lt;br /&gt;
== Subclassing existing elements ==&lt;br /&gt;
&lt;br /&gt;
Subclassing existing elements is hard as implementation-wise identity is both object-based and name / namespace based. Therefore subclassing an existing element (currently) requires that the name / namespace does not change.&lt;br /&gt;
&lt;br /&gt;
A hack was invented to make this work: &amp;lt;code&amp;gt;&amp;amp;lt;button is=&amp;quot;my-button&amp;quot;&amp;gt;&amp;lt;/code&amp;gt;. That hack is not well liked leaving us two options:&lt;br /&gt;
&lt;br /&gt;
* We leave this for now and work on this in parallel while stabilizing a smaller subset of custom elements.&lt;br /&gt;
* We block on this and delay even more.&lt;br /&gt;
&lt;br /&gt;
However, without this hack accessibility for trivial components is harder as more things have to be done by hand.&lt;br /&gt;
&lt;br /&gt;
(Assuming that not all implementers are suddenly going to be okay with this hack.)&lt;br /&gt;
&lt;br /&gt;
Another use case had emerged for the &amp;quot;is&amp;quot; hack: piggy-backing on parser behaviors. For example, extending &amp;lt;code&amp;gt;&amp;amp;lt;template&amp;gt;&amp;lt;/code&amp;gt; for [https://blog.polymer-project.org/howto/2014/09/11/template-is-autobinding/ data binding] or as a way to specify [http://jsbin.com/xuheb/3/edit?html,output shadow trees in HTML].&lt;br /&gt;
== ARIA integration ==&lt;br /&gt;
&lt;br /&gt;
https://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0355.html&lt;br /&gt;
&lt;br /&gt;
[[Category:Spec coordination]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Band_names&amp;diff=9255</id>
		<title>Band names</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Band_names&amp;diff=9255"/>
		<updated>2013-07-19T22:07:34Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These are band names collected from #whatwg.&lt;br /&gt;
&lt;br /&gt;
* Bogus DOM&lt;br /&gt;
* The Unpaired Surrogates&lt;br /&gt;
* Lone Surrogates&lt;br /&gt;
* The Designated Experts&lt;br /&gt;
* Spidermonkey and the GC Jitters&lt;br /&gt;
* Polyglot Heartbeat&lt;br /&gt;
* Extant Web Corpus&lt;br /&gt;
* Ambushed by Ambiguity&lt;br /&gt;
* Ambiguous Ampersands&lt;br /&gt;
* bad value robot&lt;br /&gt;
&lt;br /&gt;
== Album titles ==&lt;br /&gt;
&lt;br /&gt;
* User Bang Important Rule&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Components&amp;diff=8912</id>
		<title>Components</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Components&amp;diff=8912"/>
		<updated>2013-01-11T20:42:43Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page discusses pros and cons of various inline component binding syntaxes.&lt;br /&gt;
&lt;br /&gt;
The hard requirements are:&lt;br /&gt;
# The binding has to be done at element creation time&lt;br /&gt;
# The binding has to be immutable during element lifetime&lt;br /&gt;
# The syntax must not make authors think the binding is mutable&lt;br /&gt;
# The syntax must be as terse as possible&lt;br /&gt;
# The syntax has to convey the element&#039;s standard semantics (a specified HTML tag name) in the document markup, for legacy UAs and future non-supporting UAs like spiders.&lt;br /&gt;
# Musn&#039;t step on the HTML vocabulary namespace (where it would prevent future standard extensions)&lt;br /&gt;
# Needs to encourage authors to put a real semantic rather than just skipping that step.&lt;br /&gt;
&lt;br /&gt;
The proposals below show the syntax for binding a &amp;quot;geomap&amp;quot; component to a &amp;amp;lt;select&amp;gt; element:&lt;br /&gt;
&lt;br /&gt;
== Proposal: &amp;amp;lt;geomap&amp;gt;&amp;amp;lt;/geomap&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Meets: 1, 2, 3, 4&lt;br /&gt;
Fails: 5, 6, 7&lt;br /&gt;
&lt;br /&gt;
Pro: Looks good to the original author — this is the closest thing to extending the language that we could do.&lt;br /&gt;
Con: Doesn&#039;t say what the standard semantic is.&lt;br /&gt;
&lt;br /&gt;
== Proposal: &amp;amp;lt;x-geomap&amp;gt;&amp;amp;lt;/x-geomap&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Meets: 1, 2, 3, 4, 6&lt;br /&gt;
Fails: 5, 7&lt;br /&gt;
&lt;br /&gt;
Pro: Looks like a new element.&lt;br /&gt;
Con: Doesn&#039;t say what the standard semantic is. The &amp;quot;x-&amp;quot; prefix is ugly.&lt;br /&gt;
&lt;br /&gt;
== Proposal: &amp;amp;lt;select is=&amp;quot;geomap&amp;quot;&amp;gt; .. &amp;amp;lt;/select&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Meets: 1, 2, 5, 6, 7&lt;br /&gt;
Fails: 3, 4&lt;br /&gt;
&lt;br /&gt;
Pro: No parser change.&lt;br /&gt;
Con: Makes authors think they can change the binding.&lt;br /&gt;
&lt;br /&gt;
== Proposal: &amp;amp;lt;select/geomap&amp;gt; .. &amp;amp;lt;/select&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Meets: 1, 2, 3, 4, 5, 6, 7&lt;br /&gt;
&lt;br /&gt;
Pro: Meets all requirements.&lt;br /&gt;
Con: Requires parser changes.&lt;br /&gt;
&lt;br /&gt;
== Proposal: &amp;amp;lt;x-geomap&amp;gt;&amp;amp;lt;select&amp;gt; .. &amp;amp;lt;/select&amp;gt;&amp;amp;lt;/x-geomap&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Meets: 1, 2, 3, 5, 6&lt;br /&gt;
Fails: 4, 7&lt;br /&gt;
&lt;br /&gt;
Pro: Looks like it allows new elements.&lt;br /&gt;
Con: Doesn&#039;t actually bind the component to the fallback, so you end up with two elements instead of one. Authors will quickly stop including the fallback when they realise it doesn&#039;t give _them_ any immediate benefit.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Use_Cases&amp;diff=7795</id>
		<title>Component Model Use Cases</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Use_Cases&amp;diff=7795"/>
		<updated>2011-11-29T18:12:37Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span style=&amp;quot;color:Red&amp;quot;&amp;gt;This page is deprecated. New work is here: http://www.w3.org/2008/webapps/wiki/Component_Model_Use_Cases&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These use cases represent a set of problems we are trying to solve by implementing a [[Component_Model | component model]] for the web. &lt;br /&gt;
&lt;br /&gt;
=Custom Controls=&lt;br /&gt;
&lt;br /&gt;
Current practice for sizable web applications is to use JavaScript libraries to provide a system to support the construction of custom controls. Implementing these controls can be made simpler and more interoperable with runtime support.&lt;br /&gt;
&lt;br /&gt;
==Layout Manager==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Layout Manager Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build a layout library, consisting of a UI layout primitives, such as &#039;&#039;panel&#039;&#039;, &#039;&#039;resizeable panel&#039;&#039;, &#039;&#039;tab group&#039;&#039;, &#039;&#039;stack&#039;&#039;, &#039;&#039;accordion containers&#039;&#039;, etc.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Allow web application developers to easily build constrained layout and populate it with arbitrary HTML content.&lt;br /&gt;
* Provide a way for developers to build their own layout primitives by extending the provided ones.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://dojotoolkit.org/reference-guide/dijit/layout.html#dijit-layout Dijit Layout]&lt;br /&gt;
* [http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html GWT Panels]&lt;br /&gt;
* [http://dev.sencha.com/deploy/ext-4.0.2a/docs/#/api/Ext.panel.AbstractPanel Sencha Panels]&lt;br /&gt;
* [http://guides.sproutcore.com/views.html SproutCore Views]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- a method to compose layouts with both UI primitives and DOM elements.&lt;br /&gt;
* [[Component_Model#Extensibility | Extensibility]] -- a way to build on layout primitives to create new ones.&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- styles, defined to hold layout in place should not be in danger of being stomped on by the author stylesheets.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- layouts built with layout manager should appear quickly, avoiding re-flows and [http://en.wikipedia.org/wiki/Flash_of_unstyled_content FOUC]-like symptoms.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Widget Mix-and-Match==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Mix-and-matching Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build an application using multiple existing controls from several frameworks.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Write application faster by reusing code.&lt;br /&gt;
* Avoid having to exclusively go with one framework.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://stackoverflow.com/questions/4534274/how-do-you-access-dijit-elements-in-jquery How do you access Dijit elements in JQuery]&lt;br /&gt;
* [http://yehudakatz.com/2011/06/11/using-sproutcore-2-0-with-jquery-ui/ Using SproutCore 2.0 with jQuery UI]&lt;br /&gt;
* [http://stackoverflow.com/questions/394601/which-javascript-framework-jquery-vs-dojo-vs Which JavaScript framework (jQuery vs Dojo vs … )?]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Consistency | Consistency]] -- a compatible way to expose properties and methods across widget frameworks.&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- a method to compose with cross-framework widgets.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Rendering Form Controls with SVG==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | SVG Form Controls Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer or Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Create a set of UI controls that act like standard HTML forms controls, but use SVG for rendering.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Provide custom appearance of form controls, consistent with overall the Web application theme.&lt;br /&gt;
* Make the form controls scale beautifully for various resolutions and form factors. &lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
[http://docs.sproutcore.com/#doc=SC.ImageButtonView&amp;amp;src=false SproutCore&#039;s ImageButtonView], [http://dev.sencha.com/deploy/touch/docs/?class=Ext.form.Number Sencha&#039;s Number] -- examples of extensive themed form control hierarchy.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Consistency | Consistency]] -- the controls should act just like any other DOM elements.&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- the document shouldn&#039;t be able to accidentally mess up the rendering of the controls.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- load quickly, avoid [http://en.wikipedia.org/wiki/Flash_of_unstyled_content FOUC]-like symptoms when using controls.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Contacts Widget==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Contacts Widget Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build a drop-in Contacts widget, which has a pre-defined appearance and shows a list of your contacts, with a way to change the widget to compact or full view and to tell the widget to refresh its state.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Use the widget anywhere in the application without having to worry about styles affecting its appearance.&lt;br /&gt;
* Hide details of loading contact data and other plumbing of the widget from the consuming code with a stable API.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
| [http://i.imgur.com/4eDXM.png A screenshot of Google+ &amp;quot;in your circles&amp;quot; widget]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- means to ensure style of the document does not affect the widget, and widget&#039;s logic is kept to the widget.&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- easily added anywhere in the DOM tree.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Like/+1 Button==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Like/+1 Button Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build a drop-in widget with a pre-defined appearance of a button, showing a count of likes/+1s for this instance of a button (count is stored at a central location), embeddable on any document on the Web.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Provide a simple vehicle for Web authors to embed the button.&lt;br /&gt;
* Isolate widget implementation details from the document.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://developers.facebook.com/docs/reference/plugins/like/ Facebook Like button embedding instructions]&lt;br /&gt;
* [http://www.google.com/webmasters/+1/button/ Google +1 button embedding instructions]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- means to ensure style of the document does not affect the widget, and widget&#039;s logic is kept to the widget.&lt;br /&gt;
* [[Component_Model#Confinement | Confinement]] -- a way to completely isolate the widget implementation from the document in which it is being embedded.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- don&#039;t block the page load.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Table-based Charts==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Table-based Charts Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Provide a way to represent table data markup as charts or diagrams.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
| Make it easy for Web authors to create charts and diagrams using table markup.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://www.wait-till-i.com/2008/01/08/generating-charts-from-accessible-data-tables-using-the-google-charts-api/ Christian Heilmann&#039;s tochart script]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- one should be able to make chart by creating a table, imperatively or declaratively.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- no FOUC or blocking load when charts are loaded.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Timezone selection via Image==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Timezone selection via Image Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Graphical representation of a timezone selector that shows a world map in addition to/instead of a drop-down list.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
| Make it easy for Web authors to spruce up time zone selection (or similar).&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://www.timezonecheck.com Time Zone Map]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Extensibility | Extensibility]] -- Basically extending &amp;amp;lt;select&amp;amp;gt;. Should fall back to a simple &amp;amp;lt;select&amp;amp;gt; where components are not supported.&lt;br /&gt;
* [[Component_Model#Consistency | Consistency]] -- Extend the &amp;amp;lt;select&amp;amp;gt; API for item selection.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Entry-helper==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Entry-helper Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Framework Engineer, Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Add an entry-helper (drop-down) list to input fields.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
| &lt;br /&gt;
Help the user fill in a form field, show suggestions and acceptable values, speed up data entry.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
| &lt;br /&gt;
* Most browser&#039;s address bar or web search field &lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Extensibility | Extensibility]] -- Basically extending &amp;amp;lt;input&amp;amp;gt;. Should fall back to a simple &amp;amp;lt;input&amp;amp;gt; where components are not supported.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Built-in HTML Elements=&lt;br /&gt;
&lt;br /&gt;
Many non-trivial (i.e. with additional behavior and styling beyond the standard box model) elements that exist in HTML today could be implemented using HTML/CSS/JS. It makes sense to provide a standardized way to accomplish this, with the short-term goals of reducing the size of browsers C++ code and making new element implementation easier, and the long-term goal of converging built-in HTML element implementations across browsers.&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Built-in HTML Elements Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Browser Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Implement a built-in HTML element by composing or extending existing HTML elements&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Reduce amount of custom UI code (fewer bugs, less code rot, leading to fewer future bugs).&lt;br /&gt;
* Remove magic: make it easier for authors to grok control behavior in familiar terms, allow authors to style controls using CSS.&lt;br /&gt;
* &#039;&#039;Stretch&#039;&#039;: specify built-in element behavior in terms of the component model specification.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- ensure that implementation details are not exposed to the document&lt;br /&gt;
* [[Component_Model#Desugaring | Desugaring]] -- explain appearance and behavior of controls in terms of CSS/DOM.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Media Controls For The Video Element==&lt;br /&gt;
&lt;br /&gt;
Using DOM elements, build a media controls panel for the [http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-video-element video element]. The media controls include:&lt;br /&gt;
* timeline slider&lt;br /&gt;
* stop/start, replay, closed-captioning, forward, rewind and volume buttons, and&lt;br /&gt;
* a volume control, which is revealed when hovering over the volume button. &lt;br /&gt;
&lt;br /&gt;
The implementation details of the media controls should not be accessible or perceptible from outside of the video element. Document styles should not interfere with the styles of the media controls panel. However, we must provide a way for an author to explicitly style all parts of the media controls panel.&lt;br /&gt;
&lt;br /&gt;
==Details/Summary Elements==&lt;br /&gt;
&lt;br /&gt;
Implement [http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-details-element details] and [http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-summary-element summary] elements. According to the spec, the first &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; element found in the flow content is used to represent a summary or legend of details. In case a &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; element is not found, the UA is supposed to auto-generate some fallback content. The &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; element itself needs to have a marker indicating whether &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; element is open or closed - i.e., whether all contents of &amp;lt;details&amp;gt; are shown, or only the summary.&lt;br /&gt;
&lt;br /&gt;
Just like media controls, the implementation should not be accessible by the consumer of the elements. For example, the reordering of flow content to position &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; element as first item in the disclosure widget should be imperceptible to DOM traversal methods.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7761</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7761"/>
		<updated>2011-11-23T19:18:13Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Current Component Model Spec] ([https://github.com/dglazkov/component-model Github project])&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in JavaScript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html DOM4]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard JavaScript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. JavaScript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the JavaScript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of JavaScript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
partial interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, life cycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Strawman pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Decorators Decorators]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Element_Registration Element Registration]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Styling Styling]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Isolation Isolation]&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Declarative_Syntax | Component Model Declarative Syntax]]&lt;br /&gt;
* [[Component_Model_Progressive_Enhancement | Component Model Progressive Enhancement]]&lt;br /&gt;
* [[Custom_Tags_Analysis | Custom Tags Analysis]]&lt;br /&gt;
&lt;br /&gt;
Discussion and brainstorming pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Discussion Main discussion page with open questions]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Discussion:_Rendering Rendering-specific discussion]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Brainstorming general brainstorming]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming brainstorming page about CSS and styling]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming brainstorming page about isolation and confinement]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Decorator_Brainstorming brainstorming page about decorators]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_IDL_Brainstorming brainstorming page about IDLs and communication across boundaries]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Aspect-oriented_Components_Brainstorming brainstorming about aspect-oriented components]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7760</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7760"/>
		<updated>2011-11-23T19:16:51Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in JavaScript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html DOM4]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard JavaScript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. JavaScript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the JavaScript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of JavaScript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
partial interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, life cycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Strawman pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Decorators Decorators]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Element_Registration Element Registration]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Styling Styling]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Strawman:_Isolation Isolation]&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Declarative_Syntax | Component Model Declarative Syntax]]&lt;br /&gt;
* [[Component_Model_Progressive_Enhancement | Component Model Progressive Enhancement]]&lt;br /&gt;
* [[Custom_Tags_Analysis | Custom Tags Analysis]]&lt;br /&gt;
&lt;br /&gt;
Discussion and brainstorming pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Discussion Main discussion page with open questions]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Discussion:_Rendering Rendering-specific discussion]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Brainstorming general brainstorming]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming brainstorming page about CSS and styling]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming brainstorming page about isolation and confinement]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Decorator_Brainstorming brainstorming page about decorators]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_IDL_Brainstorming brainstorming page about IDLs and communication across boundaries]&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Aspect-oriented_Components_Brainstorming brainstorming about aspect-oriented components]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model:_Decorator_Challenges&amp;diff=7753</id>
		<title>Component Model: Decorator Challenges</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model:_Decorator_Challenges&amp;diff=7753"/>
		<updated>2011-11-22T23:06:45Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;Back to [[Component_Model | Component Model]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The design goal for [[Behavior_Attachment | decorators]] can summarized as follows: allow runtime (dynamic) application and unapplication of presentation (and possibly behavior, associated with the presentation) to a DOM element, regardless of the current state of the element, in a way that’s performant (both in memory and time space), and intuitive for today’s Web developers.&lt;br /&gt;
&lt;br /&gt;
The problem with decorators is not their application, but the &#039;&#039;unapplication&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the decorator maintains state, this requirement of unapplication creates a difficulty of understanding when the state matters, when it no longer does, and even whether it’s the same state/instance as the one you left just a moment ago.&lt;br /&gt;
&lt;br /&gt;
For example, running script inside of the decorator forces the decorator’s author to follow rules of engagement that differ from those in typical script development -- in non-obvious ways:&lt;br /&gt;
* registering an event listener with any DOM node outside of the decorator produces undesirable effect of a listener sticking around even after the decorator is unapplied.&lt;br /&gt;
* using setInterval/setTimeout/XHR, or anything that exits event loop produces an expectation of code running after the decorator is unapplied.&lt;br /&gt;
* even just storing state inside of a decorator is challenging; in situations where decorator is unapplied/reapplied quickly (like matching a hover pseudoclass), the state is lost without any warning.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Even if we attempt to separate the state of a decorator from the element and its document using an iframe- or worker-like machinery, we’ll still have similar issues of managing decorator instances that are no longer relevant, but don’t know that yet -- in addition to the performance costs of such high-isolation approach.&lt;br /&gt;
&lt;br /&gt;
One way to remove some state uncertainty could be to pool all decorators instances and reuse them on reapplication, rather than creating new instances. Unfortunately, this means that the decorators may never be reclaimed, which impacts performance characteristics.&lt;br /&gt;
&lt;br /&gt;
We could explicitly prevent the decorator from ever having a state or being able to change it. This places a set of unorthodox (at least from author’s perspective) constraints on the DOM tree, created by the decorator. All of these constraints stem from the need to halt DOM changes in a decorator shadow subtree and include not allowing:&lt;br /&gt;
* &amp;lt;script&amp;gt; elements,&lt;br /&gt;
* contenteditable,&lt;br /&gt;
* inline event handlers,&lt;br /&gt;
* custom elements, etc.&lt;br /&gt;
&lt;br /&gt;
Conceptually, this type of arrangement is the one of  DOM projection, where there’s only one instance of the decorator’s shadow DOM subtree in existence, and each application is just a rendering of that DOM tree. While the barrier for fully grokking the frozen-state DOM could be high for authors, this is probably the highest-performing solution, since application and unapplication of a decorator is just a matter of building and tearing down a box tree.&lt;br /&gt;
&lt;br /&gt;
All approaches mentioned here have their drawbacks, and it appears we either needs to invent something better or play the game of picking lesser evils.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model:_Decorator_Challenges&amp;diff=7752</id>
		<title>Component Model: Decorator Challenges</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model:_Decorator_Challenges&amp;diff=7752"/>
		<updated>2011-11-22T22:58:24Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
The design goal for [[Behavior_Attachment | decorators]] can summarized as follows: allow runtime (dynamic) application and unapplication of presentation (and possibly behavior, associated with the presentation) to a DOM element, regardless of the current state of the element, in a way that’s performant (both in memory and time space), and intuitive for today’s Web developers.&lt;br /&gt;
&lt;br /&gt;
The problem with decorators is not their application, but the &#039;&#039;unapplication&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the decorator maintains state, this requirement of unapplication creates a difficulty of understanding when the state matters, when it no longer does, and even whether it’s the same state/instance as the one you left just a moment ago.&lt;br /&gt;
&lt;br /&gt;
For example, running script inside of the decorator forces the decorator’s author to follow rules of engagement that differ from those in typical script development -- in non-obvious ways:&lt;br /&gt;
* registering an event listener with any DOM node outside of the decorator produces undesirable effect of a listener sticking around even after the decorator is unapplied.&lt;br /&gt;
* using setInterval/setTimeout/XHR, or anything that exits event loop produces an expectation of code running after the decorator is unapplied.&lt;br /&gt;
* even just storing state inside of a decorator is challenging; in situations where decorator is unapplied/reapplied quickly (like matching a hover pseudoclass), the state is lost without any warning.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Even if we attempt to separate the state of a decorator from the element and its document using an iframe- or worker-like machinery, we’ll still have similar issues of managing decorator instances that are no longer relevant, but don’t know that yet -- in addition to the performance costs of such high-isolation approach.&lt;br /&gt;
&lt;br /&gt;
One way to remove some state uncertainty could be to pool all decorators instances and reuse them on reapplication, rather than creating new instances. Unfortunately, this means that the decorators may never be reclaimed, which impacts performance characteristics.&lt;br /&gt;
&lt;br /&gt;
We could explicitly prevent the decorator from ever having a state or being able to change it. This places a set of unorthodox (at least from author’s perspective) constraints on the DOM tree, created by the decorator. All of these constraints stem from the need to halt DOM changes in a decorator shadow subtree and include not allowing:&lt;br /&gt;
* &amp;lt;script&amp;gt; elements,&lt;br /&gt;
* contenteditable,&lt;br /&gt;
* inline event handlers,&lt;br /&gt;
* custom elements, etc.&lt;br /&gt;
&lt;br /&gt;
Conceptually, this type of arrangement is the one of  DOM projection, where there’s only one instance of the decorator’s shadow DOM subtree in existence, and each application is just a rendering of that DOM tree. While the barrier for fully grokking the frozen-state DOM could be high for authors, this is probably the highest-performing solution, since application and unapplication of a decorator is just a matter of building and tearing down a box tree.&lt;br /&gt;
&lt;br /&gt;
All approaches mentioned here have their drawbacks, and it appears we either needs to invent something better or play the game of picking lesser evils.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model:_Decorator_Challenges&amp;diff=7751</id>
		<title>Component Model: Decorator Challenges</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model:_Decorator_Challenges&amp;diff=7751"/>
		<updated>2011-11-22T22:54:11Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: Created page with &amp;#039;The design goal for decorators can summarized as follows: allow runtime (dynamic) application and unapplication to a DOM element, regardless of the current state of the element, ...&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The design goal for decorators can summarized as follows: allow runtime (dynamic) application and unapplication to a DOM element, regardless of the current state of the element, in a way that’s performant (both in memory and time space), and intuitive for today’s Web developers.&lt;br /&gt;
&lt;br /&gt;
The problem with decorators is not their application, but the &#039;&#039;unapplication&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the decorator maintains state, this requirement of unapplication creates a difficulty of understanding when the state matters, when it no longer does, and even whether it’s the same state/instance as the one you left just a moment ago.&lt;br /&gt;
&lt;br /&gt;
For example, running script inside of the decorator forces the decorator’s author to follow rules of engagement that differ from those in typical script development -- in non-obvious ways:&lt;br /&gt;
* registering an event listener with any DOM node outside of the decorator produces undesirable effect of a listener sticking around even after the decorator is unapplied.&lt;br /&gt;
* using setInterval/setTimeout/XHR, or anything that exits event loop produces an expectation of code running after the decorator is unapplied.&lt;br /&gt;
* even just storing state inside of a decorator is challenging; in situations where decorator is unapplied/reapplied quickly (like matching a hover pseudoclass), the state is lost without any warning.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Even if we attempt to separate the state of a decorator from the element and its document using an iframe- or worker-like machinery, we’ll still have similar issues of managing decorator instances that are no longer relevant, but don’t know that yet -- in addition to the performance costs of such high-isolation approach.&lt;br /&gt;
&lt;br /&gt;
One way to remove some state uncertainty could be to pool all decorators instances and reuse them on reapplication, rather than creating new instances. Unfortunately, this means that the decorators may never be reclaimed, which impacts performance characteristics.&lt;br /&gt;
&lt;br /&gt;
We could explicitly prevent the decorator from ever having a state or being able to change it. This places a set of unorthodox (at least from author’s perspective) constraints on the DOM tree, created by the decorator. All of these constraints stem from the need to halt DOM changes in a decorator shadow subtree and include not allowing:&lt;br /&gt;
* &amp;lt;script&amp;gt; elements,&lt;br /&gt;
* contenteditable,&lt;br /&gt;
* inline event handlers,&lt;br /&gt;
* custom elements, etc.&lt;br /&gt;
&lt;br /&gt;
Conceptually, this type of arrangement is the one of  DOM projection, where there’s only one instance of the decorator’s shadow DOM subtree in existence, and each application is just a rendering of that DOM tree. While the barrier for fully grokking the frozen-state DOM could be high for authors, this is probably the highest-performing solution, since application and unapplication of a decorator is just a matter of building and tearing down a box tree.&lt;br /&gt;
&lt;br /&gt;
All approaches mentioned here have their drawbacks, and it appears we either needs to invent something better or play the game of picking lesser evils.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7271</id>
		<title>Component Model Discussion</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7271"/>
		<updated>2011-10-10T22:02:58Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
This document attempts to exhaustively list issues that we feel are unanswered or ambiguous.&lt;br /&gt;
&lt;br /&gt;
Linked pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: alternative solutions to styling&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page]: general thoughts on isolation &amp;amp; confinement&lt;br /&gt;
&lt;br /&gt;
= Issues =&lt;br /&gt;
&lt;br /&gt;
== CSS and Rendering ==&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: brainstorming on alternative solutions to styling&lt;br /&gt;
&lt;br /&gt;
Other issues:&lt;br /&gt;
&lt;br /&gt;
* styling of rendering children of &amp;amp;lt;content&amp;amp;gt; (partially discussed in the [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]).&lt;br /&gt;
* Do components create a layer?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]]: isn&#039;t this an implementation detail?&lt;br /&gt;
* tab-index behavior&lt;br /&gt;
* z-order behavior&lt;br /&gt;
&lt;br /&gt;
== Shadow Nodes ==&lt;br /&gt;
&lt;br /&gt;
* shadow root being a separate node type vs. an element vs. document fragment vs. ??? (see [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page])&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: separate node type&amp;lt;/span&amp;gt;&lt;br /&gt;
* Does ShadowRoot have innerHTML?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of &amp;amp;lt;content&amp;amp;gt; selector syntax&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;suggestion: space-separated list of selector sequences: [tag]?[class]*[id]*[attr]*[pseudo-class]* (NO pseudo-elements)&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]]: will space-separation be confusing? I like the idea, but just thought I should raise this as a concern.&lt;br /&gt;
* Can the same host element child be rendered under multiple &amp;amp;lt;content&amp;amp;gt; elements that all select it?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no - the first to select it &amp;quot;gets&amp;quot; it. &amp;amp;lt;content&amp;amp;gt; without &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; is always last in this regard&amp;lt;/span&amp;gt;&lt;br /&gt;
* Is &amp;amp;lt;content&amp;amp;gt; is a bona-fide HTML element (vs. a DOM subtype)?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Events ==&lt;br /&gt;
&lt;br /&gt;
* focus event traversing out of shadow?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes, redirected&amp;lt;/span&amp;gt;&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: not implemented&amp;lt;/span&amp;gt;&lt;br /&gt;
* instantiation events (which events &amp;amp; when?)&lt;br /&gt;
** for &amp;lt;template&amp;gt; instantiations&lt;br /&gt;
** for component instances&lt;br /&gt;
** on rebinding? (provided CSS &#039;binding&#039; is possible)&lt;br /&gt;
* event on component registration?&lt;br /&gt;
&lt;br /&gt;
== Loading and Life Cycle ==&lt;br /&gt;
&lt;br /&gt;
* loading mechanism (syntax)&lt;br /&gt;
* How to handle definition after use&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t do anything&amp;lt;/span&amp;gt;&lt;br /&gt;
* packaging&lt;br /&gt;
* is it possible to rename a component? e.g., to avoid name clashes?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* is it possible to have a scoped (private) names, e.g., for private components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* define all edge cases and “unhappy” cases. Examples: constructor throws exception (general case), constructor throws exception during parsing&lt;br /&gt;
* Is it possible to undefine a component? (if yes, how?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Registration ==&lt;br /&gt;
&lt;br /&gt;
* how to handle name clashes between components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: teach authors to add unique prefix, e.g., &amp;amp;lt;x-cyberdyne-terminator&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
* details on attaching a shadow tree?&lt;br /&gt;
** &amp;amp;lt;x-mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; flexible, tag is inherently static, most performant&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; accessibility, fall-back&lt;br /&gt;
**** &amp;amp;lt;div becomes=mywidget&amp;amp;gt; even more problematic in these regards and also requires duplication of style rules (?)&lt;br /&gt;
** &amp;amp;lt;button is=mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility of base element, natural fallback&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; not a priori obvious that &#039;is&#039; cannot be rebound, limited to existing element names&lt;br /&gt;
** CSS binding: button { binding: mywidget; }&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility and fallback, most flexible&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; implementation is hard, multiple (perhaps mutually exclusive) bindings may apply, cannot extend the API&lt;br /&gt;
** other?&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]]: Hixie suggested a mix of decorator and element, where the API is bound using magic attribute and shadow tree + events are bound using css binding.&lt;br /&gt;
* fallback mechanisms (implicit with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with fallback content as children)&lt;br /&gt;
* Are shadow trees dynamic or static?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: static, but see discussion in public-webapps@ ML&amp;lt;/span&amp;gt;&lt;br /&gt;
* accessibility (implicit, e.g. with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with ARIA roles)&lt;br /&gt;
&lt;br /&gt;
== Derivation ==&lt;br /&gt;
&lt;br /&gt;
* should we do XBL-like inheritance?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* “aspect-oriented&amp;quot; components (components defining the parts they use, derived components can override or re-use specific parts, part names automatically become pseudos)&lt;br /&gt;
* composition vs. inheritance (i.e., do we need inheritance at all, or can composition handle all use cases?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;temporary assumption: composition only&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== JavaScript  ==&lt;br /&gt;
&lt;br /&gt;
=== Subtyping of DOM Objects===&lt;br /&gt;
&lt;br /&gt;
* Can one subtype anything (text/attribute nodes, events, ...), or just HTMLElement?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: just HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of construction&lt;br /&gt;
* can one write a constructor with &amp;lt;supertype&amp;gt;.call(...), or does one have to use createElement?&lt;br /&gt;
&lt;br /&gt;
=== Isolation/Confinement ===&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Forwarding ===&lt;br /&gt;
&lt;br /&gt;
examples: sub-classing &amp;amp;lt;textarea&amp;amp;gt; (Maciej’s examples), auto-completion, omni-bar like drop-down, toolbar&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
&lt;br /&gt;
* how to handle Element.register being overwritten?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
* how to handle, e.g., appendChild being overwritten on a component?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Isolation and Confinement ==&lt;br /&gt;
&lt;br /&gt;
(see also the [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page])&lt;br /&gt;
&lt;br /&gt;
* To what degree is isolation/confinement really necessary? (scripts? DOM access? CSS properties?)&lt;br /&gt;
* How far is isolation/confinement handling for components similar to &amp;amp;lt;iframe&amp;amp;gt;?&lt;br /&gt;
* Can we substitute isolation with &amp;amp;lt;iframe&amp;amp;gt;s?&lt;br /&gt;
* Are instances of the same component isolated from each other?&lt;br /&gt;
* Are instances of the components from the same domain isolated from each other?&lt;br /&gt;
* Can instances of the same component share data somehow?&lt;br /&gt;
* Can instances of the same component and its derivatives share data somehow?&lt;br /&gt;
* Can instances of the components from the same domain share data somehow?&lt;br /&gt;
* Can isolated components position content outside the host boundary rect? (if not, problems with, e.g., +1 widget)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Declarative syntax ==&lt;br /&gt;
&lt;br /&gt;
* how/when to run scripts?&lt;br /&gt;
* syntax to style the host (provided we select a model where it is rendered)?&lt;br /&gt;
* &amp;amp;lt;template&amp;amp;gt; details:&lt;br /&gt;
** usable without components?&lt;br /&gt;
** instantiable without explicit components (e.g., &amp;amp;lt;instance select=”x-cyberdyne-terminator”&amp;amp;gt;)&lt;br /&gt;
** event handler registration syntax&lt;br /&gt;
** introduce template types (e.g., &amp;amp;lt;template type=”django”&amp;amp;gt;)?&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;amp;lt;element&amp;amp;gt; details&lt;br /&gt;
* Do we need &amp;amp;lt;binding&amp;amp;gt; as well?&lt;br /&gt;
* How to define the API of components&lt;br /&gt;
&lt;br /&gt;
== Misc. ==&lt;br /&gt;
&lt;br /&gt;
* Do we define the shadow DOM (or parts thereof) of built-in elements?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* How can we split the spec into (more) different parts?&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7270</id>
		<title>Component Model Discussion</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7270"/>
		<updated>2011-10-10T22:02:11Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Registration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
This document attempts to exhaustively list issues that we feel are unanswered or ambiguous.&lt;br /&gt;
&lt;br /&gt;
Linked pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: alternative solutions to styling&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page]: general thoughts on isolation &amp;amp; confinement&lt;br /&gt;
&lt;br /&gt;
= Issues =&lt;br /&gt;
&lt;br /&gt;
== CSS and Rendering ==&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: brainstorming on alternative solutions to styling&lt;br /&gt;
&lt;br /&gt;
Other issues:&lt;br /&gt;
&lt;br /&gt;
* styling of rendering children of &amp;amp;lt;content&amp;amp;gt; (partially discussed in the [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]).&lt;br /&gt;
* Do components create a layer?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] isn&#039;t this an implementation detail?&lt;br /&gt;
* tab-index behavior&lt;br /&gt;
* z-order behavior&lt;br /&gt;
&lt;br /&gt;
== Shadow Nodes ==&lt;br /&gt;
&lt;br /&gt;
* shadow root being a separate node type vs. an element vs. document fragment vs. ??? (see [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page])&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: separate node type&amp;lt;/span&amp;gt;&lt;br /&gt;
* Does ShadowRoot have innerHTML?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of &amp;amp;lt;content&amp;amp;gt; selector syntax&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;suggestion: space-separated list of selector sequences: [tag]?[class]*[id]*[attr]*[pseudo-class]* (NO pseudo-elements)&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] will space-separation be confusing? I like the idea, but just thought I should raise this as a concern.&lt;br /&gt;
* Can the same host element child be rendered under multiple &amp;amp;lt;content&amp;amp;gt; elements that all select it?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no - the first to select it &amp;quot;gets&amp;quot; it. &amp;amp;lt;content&amp;amp;gt; without &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; is always last in this regard&amp;lt;/span&amp;gt;&lt;br /&gt;
* Is &amp;amp;lt;content&amp;amp;gt; is a bona-fide HTML element (vs. a DOM subtype)?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Events ==&lt;br /&gt;
&lt;br /&gt;
* focus event traversing out of shadow?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes, redirected&amp;lt;/span&amp;gt;&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: not implemented&amp;lt;/span&amp;gt;&lt;br /&gt;
* instantiation events (which events &amp;amp; when?)&lt;br /&gt;
** for &amp;lt;template&amp;gt; instantiations&lt;br /&gt;
** for component instances&lt;br /&gt;
** on rebinding? (provided CSS &#039;binding&#039; is possible)&lt;br /&gt;
* event on component registration?&lt;br /&gt;
&lt;br /&gt;
== Loading and Life Cycle ==&lt;br /&gt;
&lt;br /&gt;
* loading mechanism (syntax)&lt;br /&gt;
* How to handle definition after use&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t do anything&amp;lt;/span&amp;gt;&lt;br /&gt;
* packaging&lt;br /&gt;
* is it possible to rename a component? e.g., to avoid name clashes?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* is it possible to have a scoped (private) names, e.g., for private components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* define all edge cases and “unhappy” cases. Examples: constructor throws exception (general case), constructor throws exception during parsing&lt;br /&gt;
* Is it possible to undefine a component? (if yes, how?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Registration ==&lt;br /&gt;
&lt;br /&gt;
* how to handle name clashes between components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: teach authors to add unique prefix, e.g., &amp;amp;lt;x-cyberdyne-terminator&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
* details on attaching a shadow tree?&lt;br /&gt;
** &amp;amp;lt;x-mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; flexible, tag is inherently static, most performant&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; accessibility, fall-back&lt;br /&gt;
**** &amp;amp;lt;div becomes=mywidget&amp;amp;gt; even more problematic in these regards and also requires duplication of style rules (?)&lt;br /&gt;
** &amp;amp;lt;button is=mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility of base element, natural fallback&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; not a priori obvious that &#039;is&#039; cannot be rebound, limited to existing element names&lt;br /&gt;
** CSS binding: button { binding: mywidget; }&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility and fallback, most flexible&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; implementation is hard, multiple (perhaps mutually exclusive) bindings may apply, cannot extend the API&lt;br /&gt;
** other?&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] Hixie suggested a mix of decorator and element, where the API is bound using magic attribute and shadow tree + events are bound using css binding.&lt;br /&gt;
* fallback mechanisms (implicit with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with fallback content as children)&lt;br /&gt;
* Are shadow trees dynamic or static?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: static, but see discussion in public-webapps@ ML&amp;lt;/span&amp;gt;&lt;br /&gt;
* accessibility (implicit, e.g. with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with ARIA roles)&lt;br /&gt;
&lt;br /&gt;
== Derivation ==&lt;br /&gt;
&lt;br /&gt;
* should we do XBL-like inheritance?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* “aspect-oriented&amp;quot; components (components defining the parts they use, derived components can override or re-use specific parts, part names automatically become pseudos)&lt;br /&gt;
* composition vs. inheritance (i.e., do we need inheritance at all, or can composition handle all use cases?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;temporary assumption: composition only&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== JavaScript  ==&lt;br /&gt;
&lt;br /&gt;
=== Subtyping of DOM Objects===&lt;br /&gt;
&lt;br /&gt;
* Can one subtype anything (text/attribute nodes, events, ...), or just HTMLElement?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: just HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of construction&lt;br /&gt;
* can one write a constructor with &amp;lt;supertype&amp;gt;.call(...), or does one have to use createElement?&lt;br /&gt;
&lt;br /&gt;
=== Isolation/Confinement ===&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Forwarding ===&lt;br /&gt;
&lt;br /&gt;
examples: sub-classing &amp;amp;lt;textarea&amp;amp;gt; (Maciej’s examples), auto-completion, omni-bar like drop-down, toolbar&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
&lt;br /&gt;
* how to handle Element.register being overwritten?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
* how to handle, e.g., appendChild being overwritten on a component?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Isolation and Confinement ==&lt;br /&gt;
&lt;br /&gt;
(see also the [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page])&lt;br /&gt;
&lt;br /&gt;
* To what degree is isolation/confinement really necessary? (scripts? DOM access? CSS properties?)&lt;br /&gt;
* How far is isolation/confinement handling for components similar to &amp;amp;lt;iframe&amp;amp;gt;?&lt;br /&gt;
* Can we substitute isolation with &amp;amp;lt;iframe&amp;amp;gt;s?&lt;br /&gt;
* Are instances of the same component isolated from each other?&lt;br /&gt;
* Are instances of the components from the same domain isolated from each other?&lt;br /&gt;
* Can instances of the same component share data somehow?&lt;br /&gt;
* Can instances of the same component and its derivatives share data somehow?&lt;br /&gt;
* Can instances of the components from the same domain share data somehow?&lt;br /&gt;
* Can isolated components position content outside the host boundary rect? (if not, problems with, e.g., +1 widget)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Declarative syntax ==&lt;br /&gt;
&lt;br /&gt;
* how/when to run scripts?&lt;br /&gt;
* syntax to style the host (provided we select a model where it is rendered)?&lt;br /&gt;
* &amp;amp;lt;template&amp;amp;gt; details:&lt;br /&gt;
** usable without components?&lt;br /&gt;
** instantiable without explicit components (e.g., &amp;amp;lt;instance select=”x-cyberdyne-terminator”&amp;amp;gt;)&lt;br /&gt;
** event handler registration syntax&lt;br /&gt;
** introduce template types (e.g., &amp;amp;lt;template type=”django”&amp;amp;gt;)?&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;amp;lt;element&amp;amp;gt; details&lt;br /&gt;
* Do we need &amp;amp;lt;binding&amp;amp;gt; as well?&lt;br /&gt;
* How to define the API of components&lt;br /&gt;
&lt;br /&gt;
== Misc. ==&lt;br /&gt;
&lt;br /&gt;
* Do we define the shadow DOM (or parts thereof) of built-in elements?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* How can we split the spec into (more) different parts?&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7269</id>
		<title>Component Model Discussion</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7269"/>
		<updated>2011-10-10T21:59:30Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Shadow Nodes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
This document attempts to exhaustively list issues that we feel are unanswered or ambiguous.&lt;br /&gt;
&lt;br /&gt;
Linked pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: alternative solutions to styling&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page]: general thoughts on isolation &amp;amp; confinement&lt;br /&gt;
&lt;br /&gt;
= Issues =&lt;br /&gt;
&lt;br /&gt;
== CSS and Rendering ==&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: brainstorming on alternative solutions to styling&lt;br /&gt;
&lt;br /&gt;
Other issues:&lt;br /&gt;
&lt;br /&gt;
* styling of rendering children of &amp;amp;lt;content&amp;amp;gt; (partially discussed in the [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]).&lt;br /&gt;
* Do components create a layer?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] isn&#039;t this an implementation detail?&lt;br /&gt;
* tab-index behavior&lt;br /&gt;
* z-order behavior&lt;br /&gt;
&lt;br /&gt;
== Shadow Nodes ==&lt;br /&gt;
&lt;br /&gt;
* shadow root being a separate node type vs. an element vs. document fragment vs. ??? (see [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page])&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: separate node type&amp;lt;/span&amp;gt;&lt;br /&gt;
* Does ShadowRoot have innerHTML?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of &amp;amp;lt;content&amp;amp;gt; selector syntax&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;suggestion: space-separated list of selector sequences: [tag]?[class]*[id]*[attr]*[pseudo-class]* (NO pseudo-elements)&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] will space-separation be confusing? I like the idea, but just thought I should raise this as a concern.&lt;br /&gt;
* Can the same host element child be rendered under multiple &amp;amp;lt;content&amp;amp;gt; elements that all select it?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no - the first to select it &amp;quot;gets&amp;quot; it. &amp;amp;lt;content&amp;amp;gt; without &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; is always last in this regard&amp;lt;/span&amp;gt;&lt;br /&gt;
* Is &amp;amp;lt;content&amp;amp;gt; is a bona-fide HTML element (vs. a DOM subtype)?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Events ==&lt;br /&gt;
&lt;br /&gt;
* focus event traversing out of shadow?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes, redirected&amp;lt;/span&amp;gt;&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: not implemented&amp;lt;/span&amp;gt;&lt;br /&gt;
* instantiation events (which events &amp;amp; when?)&lt;br /&gt;
** for &amp;lt;template&amp;gt; instantiations&lt;br /&gt;
** for component instances&lt;br /&gt;
** on rebinding? (provided CSS &#039;binding&#039; is possible)&lt;br /&gt;
* event on component registration?&lt;br /&gt;
&lt;br /&gt;
== Loading and Life Cycle ==&lt;br /&gt;
&lt;br /&gt;
* loading mechanism (syntax)&lt;br /&gt;
* How to handle definition after use&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t do anything&amp;lt;/span&amp;gt;&lt;br /&gt;
* packaging&lt;br /&gt;
* is it possible to rename a component? e.g., to avoid name clashes?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* is it possible to have a scoped (private) names, e.g., for private components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* define all edge cases and “unhappy” cases. Examples: constructor throws exception (general case), constructor throws exception during parsing&lt;br /&gt;
* Is it possible to undefine a component? (if yes, how?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Registration ==&lt;br /&gt;
&lt;br /&gt;
* how to handle name clashes between components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: teach authors to add unique prefix, e.g., &amp;amp;lt;x-cyberdyne-terminator&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
* details on attaching a shadow tree?&lt;br /&gt;
** &amp;amp;lt;x-mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; flexible, tag is inherently static, most performant&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; accessibility, fall-back&lt;br /&gt;
**** &amp;amp;lt;div becomes=mywidget&amp;amp;gt; even more problematic in these regards and also requires duplication of style rules (?)&lt;br /&gt;
** &amp;amp;lt;button is=mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility of base element, natural fallback&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; not a priori obvious that &#039;is&#039; cannot be rebound, limited to existing element names&lt;br /&gt;
** CSS binding: button { binding: mywidget; }&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility and fallback, most flexible&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; implementation is hard, multiple (perhaps mutually exclusive) bindings may apply, cannot extend the API&lt;br /&gt;
** other?&lt;br /&gt;
* fallback mechanisms (implicit with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with fallback content as children)&lt;br /&gt;
* Are shadow trees dynamic or static?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: static, but see discussion in public-webapps@ ML&amp;lt;/span&amp;gt;&lt;br /&gt;
* accessibility (implicit, e.g. with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with ARIA roles)&lt;br /&gt;
&lt;br /&gt;
== Derivation ==&lt;br /&gt;
&lt;br /&gt;
* should we do XBL-like inheritance?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* “aspect-oriented&amp;quot; components (components defining the parts they use, derived components can override or re-use specific parts, part names automatically become pseudos)&lt;br /&gt;
* composition vs. inheritance (i.e., do we need inheritance at all, or can composition handle all use cases?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;temporary assumption: composition only&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== JavaScript  ==&lt;br /&gt;
&lt;br /&gt;
=== Subtyping of DOM Objects===&lt;br /&gt;
&lt;br /&gt;
* Can one subtype anything (text/attribute nodes, events, ...), or just HTMLElement?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: just HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of construction&lt;br /&gt;
* can one write a constructor with &amp;lt;supertype&amp;gt;.call(...), or does one have to use createElement?&lt;br /&gt;
&lt;br /&gt;
=== Isolation/Confinement ===&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Forwarding ===&lt;br /&gt;
&lt;br /&gt;
examples: sub-classing &amp;amp;lt;textarea&amp;amp;gt; (Maciej’s examples), auto-completion, omni-bar like drop-down, toolbar&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
&lt;br /&gt;
* how to handle Element.register being overwritten?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
* how to handle, e.g., appendChild being overwritten on a component?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Isolation and Confinement ==&lt;br /&gt;
&lt;br /&gt;
(see also the [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page])&lt;br /&gt;
&lt;br /&gt;
* To what degree is isolation/confinement really necessary? (scripts? DOM access? CSS properties?)&lt;br /&gt;
* How far is isolation/confinement handling for components similar to &amp;amp;lt;iframe&amp;amp;gt;?&lt;br /&gt;
* Can we substitute isolation with &amp;amp;lt;iframe&amp;amp;gt;s?&lt;br /&gt;
* Are instances of the same component isolated from each other?&lt;br /&gt;
* Are instances of the components from the same domain isolated from each other?&lt;br /&gt;
* Can instances of the same component share data somehow?&lt;br /&gt;
* Can instances of the same component and its derivatives share data somehow?&lt;br /&gt;
* Can instances of the components from the same domain share data somehow?&lt;br /&gt;
* Can isolated components position content outside the host boundary rect? (if not, problems with, e.g., +1 widget)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Declarative syntax ==&lt;br /&gt;
&lt;br /&gt;
* how/when to run scripts?&lt;br /&gt;
* syntax to style the host (provided we select a model where it is rendered)?&lt;br /&gt;
* &amp;amp;lt;template&amp;amp;gt; details:&lt;br /&gt;
** usable without components?&lt;br /&gt;
** instantiable without explicit components (e.g., &amp;amp;lt;instance select=”x-cyberdyne-terminator”&amp;amp;gt;)&lt;br /&gt;
** event handler registration syntax&lt;br /&gt;
** introduce template types (e.g., &amp;amp;lt;template type=”django”&amp;amp;gt;)?&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;amp;lt;element&amp;amp;gt; details&lt;br /&gt;
* Do we need &amp;amp;lt;binding&amp;amp;gt; as well?&lt;br /&gt;
* How to define the API of components&lt;br /&gt;
&lt;br /&gt;
== Misc. ==&lt;br /&gt;
&lt;br /&gt;
* Do we define the shadow DOM (or parts thereof) of built-in elements?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* How can we split the spec into (more) different parts?&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7268</id>
		<title>Component Model Discussion</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7268"/>
		<updated>2011-10-10T21:59:10Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Shadow Nodes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
This document attempts to exhaustively list issues that we feel are unanswered or ambiguous.&lt;br /&gt;
&lt;br /&gt;
Linked pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: alternative solutions to styling&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page]: general thoughts on isolation &amp;amp; confinement&lt;br /&gt;
&lt;br /&gt;
= Issues =&lt;br /&gt;
&lt;br /&gt;
== CSS and Rendering ==&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: brainstorming on alternative solutions to styling&lt;br /&gt;
&lt;br /&gt;
Other issues:&lt;br /&gt;
&lt;br /&gt;
* styling of rendering children of &amp;amp;lt;content&amp;amp;gt; (partially discussed in the [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]).&lt;br /&gt;
* Do components create a layer?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] isn&#039;t this an implementation detail?&lt;br /&gt;
* tab-index behavior&lt;br /&gt;
* z-order behavior&lt;br /&gt;
&lt;br /&gt;
== Shadow Nodes ==&lt;br /&gt;
&lt;br /&gt;
* shadow root being a separate node type vs. an element vs. document fragment vs. ??? (see [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page])&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: separate node type&amp;lt;/span&amp;gt;&lt;br /&gt;
* Does ShadowRoot have innerHTML?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of &amp;amp;lt;content&amp;amp;gt; selector syntax&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;suggestion: space-separated list of selector sequences: [tag]?[class]*[id]*[attr]*[pseudo-class]* (NO pseudo-elements)&amp;lt;/span&amp;gt;&lt;br /&gt;
::~~ will space-separation be confusing? I like the idea, but just thought I should raise this as a concern.&lt;br /&gt;
* Can the same host element child be rendered under multiple &amp;amp;lt;content&amp;amp;gt; elements that all select it?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no - the first to select it &amp;quot;gets&amp;quot; it. &amp;amp;lt;content&amp;amp;gt; without &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; is always last in this regard&amp;lt;/span&amp;gt;&lt;br /&gt;
* Is &amp;amp;lt;content&amp;amp;gt; is a bona-fide HTML element (vs. a DOM subtype)?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Events ==&lt;br /&gt;
&lt;br /&gt;
* focus event traversing out of shadow?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes, redirected&amp;lt;/span&amp;gt;&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: not implemented&amp;lt;/span&amp;gt;&lt;br /&gt;
* instantiation events (which events &amp;amp; when?)&lt;br /&gt;
** for &amp;lt;template&amp;gt; instantiations&lt;br /&gt;
** for component instances&lt;br /&gt;
** on rebinding? (provided CSS &#039;binding&#039; is possible)&lt;br /&gt;
* event on component registration?&lt;br /&gt;
&lt;br /&gt;
== Loading and Life Cycle ==&lt;br /&gt;
&lt;br /&gt;
* loading mechanism (syntax)&lt;br /&gt;
* How to handle definition after use&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t do anything&amp;lt;/span&amp;gt;&lt;br /&gt;
* packaging&lt;br /&gt;
* is it possible to rename a component? e.g., to avoid name clashes?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* is it possible to have a scoped (private) names, e.g., for private components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* define all edge cases and “unhappy” cases. Examples: constructor throws exception (general case), constructor throws exception during parsing&lt;br /&gt;
* Is it possible to undefine a component? (if yes, how?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Registration ==&lt;br /&gt;
&lt;br /&gt;
* how to handle name clashes between components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: teach authors to add unique prefix, e.g., &amp;amp;lt;x-cyberdyne-terminator&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
* details on attaching a shadow tree?&lt;br /&gt;
** &amp;amp;lt;x-mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; flexible, tag is inherently static, most performant&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; accessibility, fall-back&lt;br /&gt;
**** &amp;amp;lt;div becomes=mywidget&amp;amp;gt; even more problematic in these regards and also requires duplication of style rules (?)&lt;br /&gt;
** &amp;amp;lt;button is=mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility of base element, natural fallback&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; not a priori obvious that &#039;is&#039; cannot be rebound, limited to existing element names&lt;br /&gt;
** CSS binding: button { binding: mywidget; }&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility and fallback, most flexible&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; implementation is hard, multiple (perhaps mutually exclusive) bindings may apply, cannot extend the API&lt;br /&gt;
** other?&lt;br /&gt;
* fallback mechanisms (implicit with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with fallback content as children)&lt;br /&gt;
* Are shadow trees dynamic or static?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: static, but see discussion in public-webapps@ ML&amp;lt;/span&amp;gt;&lt;br /&gt;
* accessibility (implicit, e.g. with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with ARIA roles)&lt;br /&gt;
&lt;br /&gt;
== Derivation ==&lt;br /&gt;
&lt;br /&gt;
* should we do XBL-like inheritance?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* “aspect-oriented&amp;quot; components (components defining the parts they use, derived components can override or re-use specific parts, part names automatically become pseudos)&lt;br /&gt;
* composition vs. inheritance (i.e., do we need inheritance at all, or can composition handle all use cases?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;temporary assumption: composition only&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== JavaScript  ==&lt;br /&gt;
&lt;br /&gt;
=== Subtyping of DOM Objects===&lt;br /&gt;
&lt;br /&gt;
* Can one subtype anything (text/attribute nodes, events, ...), or just HTMLElement?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: just HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of construction&lt;br /&gt;
* can one write a constructor with &amp;lt;supertype&amp;gt;.call(...), or does one have to use createElement?&lt;br /&gt;
&lt;br /&gt;
=== Isolation/Confinement ===&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Forwarding ===&lt;br /&gt;
&lt;br /&gt;
examples: sub-classing &amp;amp;lt;textarea&amp;amp;gt; (Maciej’s examples), auto-completion, omni-bar like drop-down, toolbar&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
&lt;br /&gt;
* how to handle Element.register being overwritten?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
* how to handle, e.g., appendChild being overwritten on a component?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Isolation and Confinement ==&lt;br /&gt;
&lt;br /&gt;
(see also the [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page])&lt;br /&gt;
&lt;br /&gt;
* To what degree is isolation/confinement really necessary? (scripts? DOM access? CSS properties?)&lt;br /&gt;
* How far is isolation/confinement handling for components similar to &amp;amp;lt;iframe&amp;amp;gt;?&lt;br /&gt;
* Can we substitute isolation with &amp;amp;lt;iframe&amp;amp;gt;s?&lt;br /&gt;
* Are instances of the same component isolated from each other?&lt;br /&gt;
* Are instances of the components from the same domain isolated from each other?&lt;br /&gt;
* Can instances of the same component share data somehow?&lt;br /&gt;
* Can instances of the same component and its derivatives share data somehow?&lt;br /&gt;
* Can instances of the components from the same domain share data somehow?&lt;br /&gt;
* Can isolated components position content outside the host boundary rect? (if not, problems with, e.g., +1 widget)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Declarative syntax ==&lt;br /&gt;
&lt;br /&gt;
* how/when to run scripts?&lt;br /&gt;
* syntax to style the host (provided we select a model where it is rendered)?&lt;br /&gt;
* &amp;amp;lt;template&amp;amp;gt; details:&lt;br /&gt;
** usable without components?&lt;br /&gt;
** instantiable without explicit components (e.g., &amp;amp;lt;instance select=”x-cyberdyne-terminator”&amp;amp;gt;)&lt;br /&gt;
** event handler registration syntax&lt;br /&gt;
** introduce template types (e.g., &amp;amp;lt;template type=”django”&amp;amp;gt;)?&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;amp;lt;element&amp;amp;gt; details&lt;br /&gt;
* Do we need &amp;amp;lt;binding&amp;amp;gt; as well?&lt;br /&gt;
* How to define the API of components&lt;br /&gt;
&lt;br /&gt;
== Misc. ==&lt;br /&gt;
&lt;br /&gt;
* Do we define the shadow DOM (or parts thereof) of built-in elements?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* How can we split the spec into (more) different parts?&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7267</id>
		<title>Component Model Discussion</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Discussion&amp;diff=7267"/>
		<updated>2011-10-10T21:48:46Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* CSS and Rendering */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
This document attempts to exhaustively list issues that we feel are unanswered or ambiguous.&lt;br /&gt;
&lt;br /&gt;
Linked pages:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: alternative solutions to styling&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page]: general thoughts on isolation &amp;amp; confinement&lt;br /&gt;
&lt;br /&gt;
= Issues =&lt;br /&gt;
&lt;br /&gt;
== CSS and Rendering ==&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page]: discussions on rendering details&lt;br /&gt;
* [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]: brainstorming on alternative solutions to styling&lt;br /&gt;
&lt;br /&gt;
Other issues:&lt;br /&gt;
&lt;br /&gt;
* styling of rendering children of &amp;amp;lt;content&amp;amp;gt; (partially discussed in the [http://wiki.whatwg.org/wiki/Component_Model_CSS_Brainstorming CSS brainstorming page]).&lt;br /&gt;
* Do components create a layer?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
::[[User:Dglazkov|Dglazkov]] isn&#039;t this an implementation detail?&lt;br /&gt;
* tab-index behavior&lt;br /&gt;
* z-order behavior&lt;br /&gt;
&lt;br /&gt;
== Shadow Nodes ==&lt;br /&gt;
&lt;br /&gt;
* shadow root being a separate node type vs. an element vs. document fragment vs. ??? (see [http://wiki.whatwg.org/index.php?title=Component_Model_Discussion:_Rendering rendering sub-page])&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: separate node type&amp;lt;/span&amp;gt;&lt;br /&gt;
* Does ShadowRoot have innerHTML?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of &amp;amp;lt;content&amp;amp;gt; selector syntax&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;suggestion: space-separated list of selector sequences: [tag]?[class]*[id]*[attr]*[pseudo-class]* (NO pseudo-elements)&amp;lt;/span&amp;gt;&lt;br /&gt;
* Can the same host element child be rendered under multiple &amp;amp;lt;content&amp;amp;gt; elements that all select it?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no - the first to select it &amp;quot;gets&amp;quot; it. &amp;amp;lt;content&amp;amp;gt; without &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; is always last in this regard&amp;lt;/span&amp;gt;&lt;br /&gt;
* Is &amp;amp;lt;content&amp;amp;gt; is a bona-fide HTML element (vs. a DOM subtype)?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Events ==&lt;br /&gt;
&lt;br /&gt;
* focus event traversing out of shadow?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;assumption: yes, redirected&amp;lt;/span&amp;gt;&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;current state: not implemented&amp;lt;/span&amp;gt;&lt;br /&gt;
* instantiation events (which events &amp;amp; when?)&lt;br /&gt;
** for &amp;lt;template&amp;gt; instantiations&lt;br /&gt;
** for component instances&lt;br /&gt;
** on rebinding? (provided CSS &#039;binding&#039; is possible)&lt;br /&gt;
* event on component registration?&lt;br /&gt;
&lt;br /&gt;
== Loading and Life Cycle ==&lt;br /&gt;
&lt;br /&gt;
* loading mechanism (syntax)&lt;br /&gt;
* How to handle definition after use&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t do anything&amp;lt;/span&amp;gt;&lt;br /&gt;
* packaging&lt;br /&gt;
* is it possible to rename a component? e.g., to avoid name clashes?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* is it possible to have a scoped (private) names, e.g., for private components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* define all edge cases and “unhappy” cases. Examples: constructor throws exception (general case), constructor throws exception during parsing&lt;br /&gt;
* Is it possible to undefine a component? (if yes, how?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Registration ==&lt;br /&gt;
&lt;br /&gt;
* how to handle name clashes between components?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: teach authors to add unique prefix, e.g., &amp;amp;lt;x-cyberdyne-terminator&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
* details on attaching a shadow tree?&lt;br /&gt;
** &amp;amp;lt;x-mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; flexible, tag is inherently static, most performant&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; accessibility, fall-back&lt;br /&gt;
**** &amp;amp;lt;div becomes=mywidget&amp;amp;gt; even more problematic in these regards and also requires duplication of style rules (?)&lt;br /&gt;
** &amp;amp;lt;button is=mywidget&amp;amp;gt;&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility of base element, natural fallback&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; not a priori obvious that &#039;is&#039; cannot be rebound, limited to existing element names&lt;br /&gt;
** CSS binding: button { binding: mywidget; }&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;Pros:&amp;lt;/span&amp;gt; accessibility and fallback, most flexible&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;Cons:&amp;lt;/span&amp;gt; implementation is hard, multiple (perhaps mutually exclusive) bindings may apply, cannot extend the API&lt;br /&gt;
** other?&lt;br /&gt;
* fallback mechanisms (implicit with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with fallback content as children)&lt;br /&gt;
* Are shadow trees dynamic or static?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: static, but see discussion in public-webapps@ ML&amp;lt;/span&amp;gt;&lt;br /&gt;
* accessibility (implicit, e.g. with &amp;amp;lt;button is=mywidget&amp;amp;gt;, explicit, e.g., with ARIA roles)&lt;br /&gt;
&lt;br /&gt;
== Derivation ==&lt;br /&gt;
&lt;br /&gt;
* should we do XBL-like inheritance?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* “aspect-oriented&amp;quot; components (components defining the parts they use, derived components can override or re-use specific parts, part names automatically become pseudos)&lt;br /&gt;
* composition vs. inheritance (i.e., do we need inheritance at all, or can composition handle all use cases?)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;temporary assumption: composition only&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== JavaScript  ==&lt;br /&gt;
&lt;br /&gt;
=== Subtyping of DOM Objects===&lt;br /&gt;
&lt;br /&gt;
* Can one subtype anything (text/attribute nodes, events, ...), or just HTMLElement?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: just HTML element&amp;lt;/span&amp;gt;&lt;br /&gt;
* details of construction&lt;br /&gt;
* can one write a constructor with &amp;lt;supertype&amp;gt;.call(...), or does one have to use createElement?&lt;br /&gt;
&lt;br /&gt;
=== Isolation/Confinement ===&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Forwarding ===&lt;br /&gt;
&lt;br /&gt;
examples: sub-classing &amp;amp;lt;textarea&amp;amp;gt; (Maciej’s examples), auto-completion, omni-bar like drop-down, toolbar&lt;br /&gt;
&lt;br /&gt;
* JS implementation details&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
&lt;br /&gt;
* how to handle Element.register being overwritten?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
* how to handle, e.g., appendChild being overwritten on a component?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: don&#039;t care&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Isolation and Confinement ==&lt;br /&gt;
&lt;br /&gt;
(see also the [http://wiki.whatwg.org/wiki/Component_Model_Isolation_Brainstorming isolation brainstorming page])&lt;br /&gt;
&lt;br /&gt;
* To what degree is isolation/confinement really necessary? (scripts? DOM access? CSS properties?)&lt;br /&gt;
* How far is isolation/confinement handling for components similar to &amp;amp;lt;iframe&amp;amp;gt;?&lt;br /&gt;
* Can we substitute isolation with &amp;amp;lt;iframe&amp;amp;gt;s?&lt;br /&gt;
* Are instances of the same component isolated from each other?&lt;br /&gt;
* Are instances of the components from the same domain isolated from each other?&lt;br /&gt;
* Can instances of the same component share data somehow?&lt;br /&gt;
* Can instances of the same component and its derivatives share data somehow?&lt;br /&gt;
* Can instances of the components from the same domain share data somehow?&lt;br /&gt;
* Can isolated components position content outside the host boundary rect? (if not, problems with, e.g., +1 widget)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: yes&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Declarative syntax ==&lt;br /&gt;
&lt;br /&gt;
* how/when to run scripts?&lt;br /&gt;
* syntax to style the host (provided we select a model where it is rendered)?&lt;br /&gt;
* &amp;amp;lt;template&amp;amp;gt; details:&lt;br /&gt;
** usable without components?&lt;br /&gt;
** instantiable without explicit components (e.g., &amp;amp;lt;instance select=”x-cyberdyne-terminator”&amp;amp;gt;)&lt;br /&gt;
** event handler registration syntax&lt;br /&gt;
** introduce template types (e.g., &amp;amp;lt;template type=”django”&amp;amp;gt;)?&lt;br /&gt;
*** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;amp;lt;element&amp;amp;gt; details&lt;br /&gt;
* Do we need &amp;amp;lt;binding&amp;amp;gt; as well?&lt;br /&gt;
* How to define the API of components&lt;br /&gt;
&lt;br /&gt;
== Misc. ==&lt;br /&gt;
&lt;br /&gt;
* Do we define the shadow DOM (or parts thereof) of built-in elements?&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;assumption: no&amp;lt;/span&amp;gt;&lt;br /&gt;
* How can we split the spec into (more) different parts?&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Use_Cases&amp;diff=7182</id>
		<title>Component Model Use Cases</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Use_Cases&amp;diff=7182"/>
		<updated>2011-09-29T19:56:50Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Like/+1 Button */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These use cases represent a set of problems we are trying to solve by implementing a [[Component_Model | component model]] for the web. &lt;br /&gt;
&lt;br /&gt;
=Custom Controls=&lt;br /&gt;
&lt;br /&gt;
Current practice for sizable web applications is to use JavaScript libraries to provide a system to support the construction of custom controls. Implementing these controls can be made simpler and more interoperable with runtime support.&lt;br /&gt;
&lt;br /&gt;
==Layout Manager==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Layout Manager Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build a layout library, consisting of a UI layout primitives, such as &#039;&#039;panel&#039;&#039;, &#039;&#039;resizeable panel&#039;&#039;, &#039;&#039;tab group&#039;&#039;, &#039;&#039;stack&#039;&#039;, &#039;&#039;accordion containers&#039;&#039;, etc.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Allow web application developers to easily build constrained layout and populate it with arbitrary HTML content.&lt;br /&gt;
* Provide a way for developers to build their own layout primitives by extending the provided ones.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://dojotoolkit.org/reference-guide/dijit/layout.html#dijit-layout Dijit Layout]&lt;br /&gt;
* [http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html GWT Panels]&lt;br /&gt;
* [http://dev.sencha.com/deploy/ext-4.0.2a/docs/#/api/Ext.panel.AbstractPanel Sencha Panels]&lt;br /&gt;
* [http://guides.sproutcore.com/views.html SproutCore Views]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- a method to compose layouts with both UI primitives and DOM elements.&lt;br /&gt;
* [[Component_Model#Extensibility | Extensibility]] -- a way to build on layout primitives to create new ones.&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- styles, defined to hold layout in place should not be in danger of being stomped on by the author stylesheets.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- layouts built with layout manager should appear quickly, avoiding re-flows and [http://en.wikipedia.org/wiki/Flash_of_unstyled_content FOUC]-like symptoms.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Widget Mix-and-Match==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Mix-and-matching Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build an application using multiple existing controls from several frameworks.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Write application faster by reusing code.&lt;br /&gt;
* Avoid having to exclusively go with one framework.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://stackoverflow.com/questions/4534274/how-do-you-access-dijit-elements-in-jquery How do you access Dijit elements in JQuery]&lt;br /&gt;
* [http://yehudakatz.com/2011/06/11/using-sproutcore-2-0-with-jquery-ui/ Using SproutCore 2.0 with jQuery UI]&lt;br /&gt;
* [http://stackoverflow.com/questions/394601/which-javascript-framework-jquery-vs-dojo-vs Which JavaScript framework (jQuery vs Dojo vs … )?]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Consistency | Consistency]] -- a compatible way to expose properties and methods across widget frameworks.&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- a method to compose with cross-framework widgets.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Rendering Form Controls with SVG==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | SVG Form Controls Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer or Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Create a set of UI controls that act like standard HTML forms controls, but use SVG for rendering.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Provide custom appearance of form controls, consistent with overall the Web application theme.&lt;br /&gt;
* Make the form controls scale beautifully for various resolutions and form factors. &lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
[http://docs.sproutcore.com/#doc=SC.ImageButtonView&amp;amp;src=false SproutCore&#039;s ImageButtonView], [http://dev.sencha.com/deploy/touch/docs/?class=Ext.form.Number Sencha&#039;s Number] -- examples of extensive themed form control hierarchy.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Consistency | Consistency]] -- the controls should act just like any other DOM elements.&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- the document shouldn&#039;t be able to accidentally mess up the rendering of the controls.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- load quickly, avoid [http://en.wikipedia.org/wiki/Flash_of_unstyled_content FOUC]-like symptoms when using controls.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Contacts Widget==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Contacts Widget Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build a drop-in Contacts widget, which has a pre-defined appearance and shows a list of your contacts, with a way to change the widget to compact or full view and to tell the widget to refresh its state.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Use the widget anywhere in the application without having to worry about styles affecting its appearance.&lt;br /&gt;
* Hide details of loading contact data and other plumbing of the widget from the consuming code with a stable API.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
| [http://i.imgur.com/4eDXM.png A screenshot of Google+ &amp;quot;in your circles&amp;quot; widget]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- means to ensure style of the document does not affect the widget, and widget&#039;s logic is kept to the widget.&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- easily added anywhere in the DOM tree.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Like/+1 Button==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Like/+1 Button Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Application Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Build a drop-in widget with a pre-defined appearance of a button, showing a count of likes/+1s for this instance of a button (count is stored at a central location), embeddable on any document on the Web.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Provide a simple vehicle for Web authors to embed the button.&lt;br /&gt;
* Isolate widget implementation details from the document.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://developers.facebook.com/docs/reference/plugins/like/ Facebook Like button embedding instructions]&lt;br /&gt;
* [http://www.google.com/webmasters/+1/button/ Google +1 button embedding instructions]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- means to ensure style of the document does not affect the widget, and widget&#039;s logic is kept to the widget.&lt;br /&gt;
* [[Component_Model#Confinement | Confinement]] -- a way to completely isolate the widget implementation from the document in which it is being embedded.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- don&#039;t block the page load.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Table-based Charts==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Table-based Charts Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Web Framework Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Provide a way to represent table data markup as charts or diagrams.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
Make it easy for Web authors to create charts and diagrams using table markup.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Examples&lt;br /&gt;
|&lt;br /&gt;
* [http://www.wait-till-i.com/2008/01/08/generating-charts-from-accessible-data-tables-using-the-google-charts-api/ Christian Heilmann&#039;s tochart script]&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Composability | Composability]] -- one should be able to make chart by creating a table, imperatively or declaratively.&lt;br /&gt;
* [[Component_Model#Performance | Performance]] -- no FOUC or blocking load when charts are loaded.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Built-in HTML Elements=&lt;br /&gt;
&lt;br /&gt;
Many non-trivial (i.e. with additional behavior and styling beyond the standard box model) elements that exist in HTML today could be implemented using HTML/CSS/JS. It makes sense to provide a standardized way to accomplish this, with the short-term goals of reducing the size of browsers C++ code and making new element implementation easier, and the long-term goal of converging built-in HTML element implementations across browsers.&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;8&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;caption-side:top; text-align: left; color:Gray&amp;quot; | Built-in HTML Elements Use Case Parameters&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Who&lt;br /&gt;
| Browser Engineer&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | What&lt;br /&gt;
| Implement a built-in HTML element by composing or extending existing HTML elements&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Purpose&lt;br /&gt;
|&lt;br /&gt;
* Reduce amount of custom UI code (fewer bugs, less code rot, leading to fewer future bugs).&lt;br /&gt;
* Remove magic: make it easier for authors to grok control behavior in familiar terms, allow authors to style controls using CSS.&lt;br /&gt;
* &#039;&#039;Stretch&#039;&#039;: specify built-in element behavior in terms of the component model specification.&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;right&amp;quot; valign=&amp;quot;top&amp;quot; | Desirable Properties&lt;br /&gt;
|&lt;br /&gt;
* [[Component_Model#Encapsulation | Encapsulation]] -- ensure that implementation details are not exposed to the document&lt;br /&gt;
* [[Component_Model#Desugaring | Desugaring]] -- explain appearance and behavior of controls in terms of CSS/DOM.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Media Controls For The Video Element==&lt;br /&gt;
&lt;br /&gt;
Using DOM elements, build a media controls panel for the [http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-video-element video element]. The media controls include:&lt;br /&gt;
* timeline slider&lt;br /&gt;
* stop/start, replay, closed-captioning, forward, rewind and volume buttons, and&lt;br /&gt;
* a volume control, which is revealed when hovering over the volume button. &lt;br /&gt;
&lt;br /&gt;
The implementation details of the media controls should not be accessible or perceptible from outside of the video element. Document styles should not interfere with the styles of the media controls panel. However, we must provide a way for an author to explicitly style all parts of the media controls panel.&lt;br /&gt;
&lt;br /&gt;
==Details/Summary Elements==&lt;br /&gt;
&lt;br /&gt;
Implement [http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-details-element details] and [http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-summary-element summary] elements. According to the spec, the first &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; element found in the flow content is used to represent a summary or legend of details. In case a &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; element is not found, the UA is supposed to auto-generate some fallback content. The &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; element itself needs to have a marker indicating whether &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; element is open or closed - i.e., whether all contents of &amp;lt;details&amp;gt; are shown, or only the summary.&lt;br /&gt;
&lt;br /&gt;
Just like media controls, the implementation should not be accessible by the consumer of the elements. For example, the reordering of flow content to position &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; element as first item in the disclosure widget should be imperceptible to DOM traversal methods.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7181</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7181"/>
		<updated>2011-09-29T18:29:15Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [[Component_Model_Declarative_Syntax | Component Model Declarative Syntax]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
* [[Component_Model_Progressive_Enhancement | Component Model Progressive Enhancement]]&lt;br /&gt;
* [[Custom_Tags_Analysis | Custom Tags Analysis]]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in JavaScript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html DOM4]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard JavaScript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. JavaScript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the JavaScript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of JavaScript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
partial interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, life cycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7180</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7180"/>
		<updated>2011-09-29T18:23:45Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Misuse/Abuse */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. Quite the opposite! By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, it allows authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;amp;lt;div&amp;amp;gt;) is perfectly ok, which by the way, is probably &#039;&#039;not&#039;&#039; what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. The Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. Also, though HTML will grow new tags, it won&#039;t to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed, misuse and abuse will happen. It already happens all the time. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. &lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7179</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7179"/>
		<updated>2011-09-29T18:22:38Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Misuse/Abuse */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. Quite the opposite! By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, it allows authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;amp;lt;div&amp;amp;gt;) is perfectly ok, which by the way, is probably &#039;&#039;not&#039;&#039; what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. The Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. Also, though HTML will grow new tags, it won&#039;t to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed it will happen. It already happens all the time. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. &lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7178</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7178"/>
		<updated>2011-09-29T18:21:19Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Clarity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. Quite the opposite! By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, it allows authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;amp;lt;div&amp;amp;gt;) is perfectly ok, which by the way, is probably &#039;&#039;not&#039;&#039; what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. The Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. Also, though HTML will grow new tags, it won&#039;t to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from his front porch) for using divs to build buttons and links. Those anti-patterns suck. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7177</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7177"/>
		<updated>2011-09-29T18:20:08Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Local Semantics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. Quite the opposite! By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, it allows authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. The Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. Also, though HTML will grow new tags, it won&#039;t to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from his front porch) for using divs to build buttons and links. Those anti-patterns suck. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7176</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7176"/>
		<updated>2011-09-29T18:18:50Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [[Component_Model_Declarative_Syntax | Component Model Declarative Syntax]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
* [[Custom_Tags_Analysis | Custom Tags Analysis]]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in JavaScript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html DOM4]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard JavaScript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. JavaScript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the JavaScript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of JavaScript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
partial interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, life cycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7175</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7175"/>
		<updated>2011-09-29T18:18:38Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [[Component_Model_Declarative_Syntax | Component Model Declarative Syntax]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
* [[Custom_Tags_Analysis | Custom Tags Analysis]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in JavaScript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html DOM4]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard JavaScript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. JavaScript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the JavaScript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of JavaScript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
partial interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, life cycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7174</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7174"/>
		<updated>2011-09-29T18:17:39Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Accessibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. Quite the opposite! By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, it allows authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. The Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. HTML will grow new tags, but it wont to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from his front porch) for using divs to build buttons and links. Those anti-patterns suck. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7173</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7173"/>
		<updated>2011-09-29T18:16:36Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. And likely the opposite.&lt;br /&gt;
&lt;br /&gt;
By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, you allow authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. The Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. HTML will grow new tags, but it wont to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from his front porch) for using divs to build buttons and links. Those anti-patterns suck. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7172</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7172"/>
		<updated>2011-09-29T18:11:24Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Misuse/Abuse */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. And likely the opposite.&lt;br /&gt;
&lt;br /&gt;
By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, you allow authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
Well, friends -- this train had left the station a long time ago. Alex Russell joked once that you already totally can add custom tags in HTML -- as long as you&#039;re Hixie. As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. If anything, the Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. Just grep the Web for &amp;quot;&amp;lt;x-&amp;quot; and look at the common names.&lt;br /&gt;
&lt;br /&gt;
In all seriousness, I expect HTML to grow new tags, and I think it will add a great many new things that will make authors&#039; life easier. I don&#039;t expect HTML to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from his front porch) for using divs to build buttons and links. Those anti-patterns suck. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7171</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7171"/>
		<updated>2011-09-29T18:10:52Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
The Component Model does not make accessibility any worse. And likely the opposite.&lt;br /&gt;
&lt;br /&gt;
By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, you allow authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;amp;gt;+1&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; is no worse than &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/code&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or component model support), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
Well, friends -- this train had left the station a long time ago. Alex Russell joked once that you already totally can add custom tags in HTML -- as long as you&#039;re Hixie. As HTML spec grows new tags, their meaning is only captured in a written document that&#039;s meaningless to the UAs that were built a priori. If anything, the Component Model provides an explicit path &#039;&#039;learn&#039;&#039; about the need for new elements in the spec. Just grep the Web for &amp;quot;&amp;lt;x-&amp;quot; and look at the common names.&lt;br /&gt;
&lt;br /&gt;
In all seriousness, I expect HTML to grow new tags, and I think it will add a great many new things that will make authors&#039; life easier. I don&#039;t expect HTML to grow every element ever needed -- the long tail is far too massive. Addressing this long tail in a local (meaningful in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
The Component Model explicitly requires prefixing all elements with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;, ensuring there are no conflicts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from his front porch) for using divs to build buttons and links. Those anti-patterns suck. We should not make it worse. If anything, we have an opportunity to provide a progressive enhancement vehicle, whereby authors can use components as a way for hiding implementation specifics and leaving out only the commonly established semantics in markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to describe underlying semantics of their component, coincidentally providing a proper fallback element for non-Component Model-aware UAs. It&#039;s similar to ARIA, but the machinery is about populating the DOM tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in markup, and, through the magic of computing, this element &#039;&#039;becomes&#039;&#039; your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;amp;gt;Weee!!&amp;amp;lt;/button&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-awesome-button&amp;amp;gt;Weee!!&amp;amp;lt;/x-awesome-button&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following [[Component_Model_Progressive_Enhancement|this algorithm]].&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7170</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7170"/>
		<updated>2011-09-29T18:05:06Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
I contend that the Component Model does not make accessibility any worse. And likely the opposite.&lt;br /&gt;
&lt;br /&gt;
By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, you allow authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;gt;+1&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;amp;lt;/x-accordion&amp;amp;gt; is no worse than &amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or Component Model plumbing), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;amp;lt;x-accordion&amp;amp;gt;&amp;lt;/code&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;code&amp;gt;&amp;amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
Well, friends -- this train had left the station a long time ago. Alex&lt;br /&gt;
Russell joked once that you already totally can add custom tags in&lt;br /&gt;
HTML -- as long as you&#039;re Hixie. As HTML spec grows new tags, their&lt;br /&gt;
meaning is only captured in a written document that&#039;s meaningless to&lt;br /&gt;
the UAs that were built a priori. If anything, the Component Model&lt;br /&gt;
provides an explicit path _learn_ about the need for new elements in&lt;br /&gt;
the spec. Just grep the Web for &amp;quot;&amp;lt;x-&amp;quot; and look at the common names.&lt;br /&gt;
&lt;br /&gt;
In all seriousness, I expect HTML to grow new tags, and I think it&lt;br /&gt;
will add a great many new things that will make authors&#039; life easier.&lt;br /&gt;
I don&#039;t expect HTML to grow every element ever needed -- the long tail&lt;br /&gt;
is far too massive. Addressing this long tail in a local (meaningful&lt;br /&gt;
in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
Well, here, FTFY -- the Component Model explicitly requires prefixing&lt;br /&gt;
all elements with &amp;quot;x-&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from&lt;br /&gt;
his front porch) for using divs to build buttons and links. Those&lt;br /&gt;
anti-patterns suck. We should not make it worse. If anything, we have&lt;br /&gt;
an opportunity to provide a progressive enhancement vehicle, whereby&lt;br /&gt;
authors can use components as a way for hiding implementation&lt;br /&gt;
specifics and leaving out only the commonly established semantics in&lt;br /&gt;
markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to&lt;br /&gt;
describe underlying semantics of their component, coincidentally&lt;br /&gt;
providing a proper fallback element for non-Component Model-aware UAs.&lt;br /&gt;
It&#039;s similar to ARIA, but the machinery is about populating the DOM&lt;br /&gt;
tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in&lt;br /&gt;
markup, and, through the magic of computing, this element _becomes_&lt;br /&gt;
your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;gt;Weee!!&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;x-awesome-button&amp;gt;Weee!!&amp;lt;/x-awesome-button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As soon as:&lt;br /&gt;
1) the definition of &amp;quot;x-awesome-button&amp;quot; is registered and;&lt;br /&gt;
2) the element is in the DOM tree.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7169</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7169"/>
		<updated>2011-09-29T18:02:46Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model | Component Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
I contend that the Component Model does not make accessibility any worse. And likely the opposite.&lt;br /&gt;
&lt;br /&gt;
By allowing ATs to traverse into shadow subtrees, and ensuring that the shadow subtrees are well-behaving accessibility citizens, you allow authors of components to encapsulate good practices and aid in killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha, SproutCore, Dijit all try to do -- and the Component Model will enable them do this right. In fact, things like access keys or even z-index are quite hard (impossible) to get right, unless you have something like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re in business of sub-typing HTML elements, we don&#039;t necessarily need to forego their semantics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;gt;+1&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;x-accordion&amp;gt;&amp;lt;/x-accordion&amp;gt; is no worse than &amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; in every mechanical sense. In the absence of definition for &amp;quot;x-accordion&amp;quot; (or Component Model plumbing), both mean the same thing, both can be styled in the same way. One is HTMLUnknownElement, the other is HTMLDivElement, and their API surface is identical.&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;x-accordion&amp;gt; clearly identifies the type of the behavior expected from the element, and conveys element behavior attachment nicely. On the other hand, &amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;gt; implies decorator behavior attachement, e.g. that removing the class value (and thus turning it back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is probably _not_ what the author of the Accordion component expects &amp;quot;in real life&amp;quot;. I mean, you can &#039;&#039;make&#039;&#039; the author expect that, but that seems like cruel and unusual punishment. In other words -- it&#039;s quite the opposite. Custom tags are more &#039;&#039;clear&#039;&#039;. In fact, they are as close as &#039;&#039;&#039;saying what you mean&#039;&#039;&#039; as it gets.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
Well, friends -- this train had left the station a long time ago. Alex&lt;br /&gt;
Russell joked once that you already totally can add custom tags in&lt;br /&gt;
HTML -- as long as you&#039;re Hixie. As HTML spec grows new tags, their&lt;br /&gt;
meaning is only captured in a written document that&#039;s meaningless to&lt;br /&gt;
the UAs that were built a priori. If anything, the Component Model&lt;br /&gt;
provides an explicit path _learn_ about the need for new elements in&lt;br /&gt;
the spec. Just grep the Web for &amp;quot;&amp;lt;x-&amp;quot; and look at the common names.&lt;br /&gt;
&lt;br /&gt;
In all seriousness, I expect HTML to grow new tags, and I think it&lt;br /&gt;
will add a great many new things that will make authors&#039; life easier.&lt;br /&gt;
I don&#039;t expect HTML to grow every element ever needed -- the long tail&lt;br /&gt;
is far too massive. Addressing this long tail in a local (meaningful&lt;br /&gt;
in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
Well, here, FTFY -- the Component Model explicitly requires prefixing&lt;br /&gt;
all elements with &amp;quot;x-&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from&lt;br /&gt;
his front porch) for using divs to build buttons and links. Those&lt;br /&gt;
anti-patterns suck. We should not make it worse. If anything, we have&lt;br /&gt;
an opportunity to provide a progressive enhancement vehicle, whereby&lt;br /&gt;
authors can use components as a way for hiding implementation&lt;br /&gt;
specifics and leaving out only the commonly established semantics in&lt;br /&gt;
markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to&lt;br /&gt;
describe underlying semantics of their component, coincidentally&lt;br /&gt;
providing a proper fallback element for non-Component Model-aware UAs.&lt;br /&gt;
It&#039;s similar to ARIA, but the machinery is about populating the DOM&lt;br /&gt;
tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in&lt;br /&gt;
markup, and, through the magic of computing, this element _becomes_&lt;br /&gt;
your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;gt;Weee!!&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;x-awesome-button&amp;gt;Weee!!&amp;lt;/x-awesome-button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As soon as:&lt;br /&gt;
1) the definition of &amp;quot;x-awesome-button&amp;quot; is registered and;&lt;br /&gt;
2) the element is in the DOM tree.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7168</id>
		<title>Custom Tags Analysis</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Custom_Tags_Analysis&amp;diff=7168"/>
		<updated>2011-09-29T17:57:06Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: Created page with &amp;#039;The Component_Model proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http:/...&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[Component_Model]] proposes using custom HTML tags (prefixed with &amp;lt;code&amp;gt;x-&amp;lt;/code&amp;gt;) as a way to express components in markup. This is motivated by the need to provide [http://wiki.whatwg.org/wiki/Behavior_Attachment element behavior attachment]. This analysis studies the issues associated with using custom tags in HTML.&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
I contend that the Component Model does not make accessibility any&lt;br /&gt;
worse. And likely the opposite.&lt;br /&gt;
&lt;br /&gt;
By allowing ATs to traverse into shadow subtrees, and ensuring that&lt;br /&gt;
the shadow subtrees are well-behaving accessibility citizens, you&lt;br /&gt;
allow authors of components to encapsulate good practices and aid in&lt;br /&gt;
killing the &amp;quot;re-created poorly&amp;quot; anti-pattern. That&#039;s what Sencha,&lt;br /&gt;
SproutCore, Dijit all try to do -- and the Component Model will enable&lt;br /&gt;
them do this right. In fact, things like access keys or even z-index&lt;br /&gt;
are quite hard (impossible) to get right, unless you have something&lt;br /&gt;
like a well-functioning shadow DOM.&lt;br /&gt;
&lt;br /&gt;
This leaves us with the argument of replacing semantics. Since we&#039;re&lt;br /&gt;
in business of sub-typing HTML elements, we don&#039;t necessarily need to&lt;br /&gt;
forego their semantics:&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
var AwesomeButton = HTMLButtonElement.extend(awesomeButtonInitializerBag);&lt;br /&gt;
Element.register(&#039;x-awesome-button&#039;, AwesomeButton);&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
should give you a thing that behaves like a button, with the awesome&lt;br /&gt;
behavior added.&lt;br /&gt;
&lt;br /&gt;
In the situations where existing semantics are representative, but&lt;br /&gt;
deficient, you are much better off replacing them anyway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;button becomes=&amp;quot;x-plus-one-button&amp;quot;&amp;gt;+1&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Behavior Fallback==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;x-accordion&amp;gt;&amp;lt;/x-accordion&amp;gt; is no worse than &amp;lt;div&lt;br /&gt;
class=&amp;quot;accordion&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; in every mechanical sense. In the absence of&lt;br /&gt;
definition for &amp;quot;x-accordion&amp;quot; (or Component Model plumbing), both mean&lt;br /&gt;
the same thing, both can be styled in the same way. One is&lt;br /&gt;
HTMLUnknownElement, the other is HTMLDivElement, and their API surface&lt;br /&gt;
is identical. So... no fallback problems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Clarity==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;x-accordion&amp;gt; clearly identifies the type of the behavior expected&lt;br /&gt;
from the element, and conveys element behavior attachment nicely. On&lt;br /&gt;
the other hand, &amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;gt; implies decorator behavior&lt;br /&gt;
attachement, e.g. that removing the class value (and thus turning it&lt;br /&gt;
back into a vanilla &amp;lt;div&amp;gt;) is perfectly ok, which by the way, is&lt;br /&gt;
probably _not_ what the author of the Accordion component expects &amp;quot;in&lt;br /&gt;
real life&amp;quot;. I mean, you can _make_ the author expect that, but that&lt;br /&gt;
seems like cruel and unusual punishment.&lt;br /&gt;
&lt;br /&gt;
In other words -- it&#039;s quite the opposite. Custom tags are more&lt;br /&gt;
_clear_. In fact, they are as close as _saying_what_you_mean_ as it&lt;br /&gt;
gets.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Local Semantics==&lt;br /&gt;
&lt;br /&gt;
Well, friends -- this train had left the station a long time ago. Alex&lt;br /&gt;
Russell joked once that you already totally can add custom tags in&lt;br /&gt;
HTML -- as long as you&#039;re Hixie. As HTML spec grows new tags, their&lt;br /&gt;
meaning is only captured in a written document that&#039;s meaningless to&lt;br /&gt;
the UAs that were built a priori. If anything, the Component Model&lt;br /&gt;
provides an explicit path _learn_ about the need for new elements in&lt;br /&gt;
the spec. Just grep the Web for &amp;quot;&amp;lt;x-&amp;quot; and look at the common names.&lt;br /&gt;
&lt;br /&gt;
In all seriousness, I expect HTML to grow new tags, and I think it&lt;br /&gt;
will add a great many new things that will make authors&#039; life easier.&lt;br /&gt;
I don&#039;t expect HTML to grow every element ever needed -- the long tail&lt;br /&gt;
is far too massive. Addressing this long tail in a local (meaningful&lt;br /&gt;
in your document), organized fashion is what the Component Model does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicts with new HTML tags==&lt;br /&gt;
&lt;br /&gt;
Well, here, FTFY -- the Component Model explicitly requires prefixing&lt;br /&gt;
all elements with &amp;quot;x-&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Misuse/Abuse==&lt;br /&gt;
&lt;br /&gt;
Indeed they will. I yell regularly at authors (like that old man from&lt;br /&gt;
his front porch) for using divs to build buttons and links. Those&lt;br /&gt;
anti-patterns suck. We should not make it worse. If anything, we have&lt;br /&gt;
an opportunity to provide a progressive enhancement vehicle, whereby&lt;br /&gt;
authors can use components as a way for hiding implementation&lt;br /&gt;
specifics and leaving out only the commonly established semantics in&lt;br /&gt;
markup. Soo.. how would something like this work?&lt;br /&gt;
&lt;br /&gt;
We need a way to let the authors specify a well-known element to&lt;br /&gt;
describe underlying semantics of their component, coincidentally&lt;br /&gt;
providing a proper fallback element for non-Component Model-aware UAs.&lt;br /&gt;
It&#039;s similar to ARIA, but the machinery is about populating the DOM&lt;br /&gt;
tree with the most-specific thing, while keeping markup most-generic.&lt;br /&gt;
&lt;br /&gt;
To put it differently, you want to start with a well-known element in&lt;br /&gt;
markup, and, through the magic of computing, this element _becomes_&lt;br /&gt;
your component in the DOM tree. In other words, the markup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;button becomes=&amp;quot;x-awesome-button&amp;quot;&amp;gt;Weee!!&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;x-awesome-button&amp;gt;Weee!!&amp;lt;/x-awesome-button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As soon as:&lt;br /&gt;
1) the definition of &amp;quot;x-awesome-button&amp;quot; is registered and;&lt;br /&gt;
2) the element is in the DOM tree.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7134</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7134"/>
		<updated>2011-09-13T18:03:57Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Progressive_Enhancement&amp;diff=7100</id>
		<title>Component Model Progressive Enhancement</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Progressive_Enhancement&amp;diff=7100"/>
		<updated>2011-08-31T17:48:21Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: Created page with &amp;#039;A. While adding an element to a DOM tree: # Check for existence of the &amp;lt;code&amp;gt;becomes&amp;lt;/code&amp;gt; attribute. If the attribute exists: ## Check the value of  the &amp;lt;code&amp;gt;becomes&amp;lt;/code&amp;gt; at...&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A. While adding an element to a DOM tree:&lt;br /&gt;
# Check for existence of the &amp;lt;code&amp;gt;becomes&amp;lt;/code&amp;gt; attribute. If the attribute exists:&lt;br /&gt;
## Check the value of  the &amp;lt;code&amp;gt;becomes&amp;lt;/code&amp;gt; attribute against the names of already defined elements. &lt;br /&gt;
### If such element exists, go to step X.&lt;br /&gt;
### Otherwise, store a reference to this instance in a &amp;quot;may-become&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
B. When a new element is registered:&lt;br /&gt;
# Check to see if there are any instances waiting in the &amp;quot;may-become&amp;quot; table for this element&#039;s name&lt;br /&gt;
# If so, collect all these instances and, for each instance, go to step X.&lt;br /&gt;
&lt;br /&gt;
C. When the &amp;quot;becomes&amp;quot; attribute is set:&lt;br /&gt;
# If the element is in tree, go to step A 1.1.&lt;br /&gt;
&lt;br /&gt;
X. Becoming another element (in Element existing instance).&lt;br /&gt;
# Create the element by the name, specified in the &amp;lt;code&amp;gt;becomes&amp;lt;/code&amp;gt; attribute of the existing instance&lt;br /&gt;
# If the existing instance is already in document tree:&lt;br /&gt;
## execute renameNode (or something better) to replace the old element with the newly created element.&lt;br /&gt;
## Otherwise, insert newly create element in DOM tree.&lt;br /&gt;
# Fire &amp;quot;&amp;lt;code&amp;gt;become&amp;lt;/code&amp;gt;&amp;quot; event on the existing instance.&lt;br /&gt;
# Set &amp;lt;code&amp;gt;became&amp;lt;/code&amp;gt; property on the existing instance to point to the newly created element.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7097</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7097"/>
		<updated>2011-08-29T21:27:12Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and isolated widgets, such as Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced ([http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode Document.renameNode]) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7096</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7096"/>
		<updated>2011-08-24T17:13:21Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Encapsulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and isolated widgets, such as Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that:&lt;br /&gt;
* no shadow DOM tree nodes cross this boundary during event dispatch;&lt;br /&gt;
* document DOM tree has no access to nodes in the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7094</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7094"/>
		<updated>2011-08-23T18:05:31Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces comprehensive support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and isolated widgets, such as Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7093</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7093"/>
		<updated>2011-08-23T18:01:08Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and isolated widgets, such as Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7092</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7092"/>
		<updated>2011-08-23T17:38:22Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Building Blocks Coverage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and encapsulated Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Use Case Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7091</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7091"/>
		<updated>2011-08-23T17:37:05Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Comparison With Existing Specs and Implementations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and encapsulated Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks Coverage=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a list of building blocks, tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Building Block&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7090</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7090"/>
		<updated>2011-08-23T17:35:39Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] draft(s) for the building blocks;&lt;br /&gt;
# Cultivate implementation feedback:&lt;br /&gt;
#* Provide experimental implementation(s) for the building blocks;&lt;br /&gt;
#* Seek feedback from the use case audiences;&lt;br /&gt;
#* Incorporate feedback into specification.&lt;br /&gt;
# Write a test suite.&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
* The specification:&lt;br /&gt;
** is a complete set of requirements for all building blocks and corner cases, discovered during implementation;&lt;br /&gt;
* The test suite:&lt;br /&gt;
** provides coverage for each requirement in the specification.&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7089</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7089"/>
		<updated>2011-08-23T17:00:00Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and encapsulated Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
* [http://dglazkov.github.com/component-model/ Component Model Spec Snapshot on Github Pages]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7088</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7088"/>
		<updated>2011-08-23T16:58:37Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and encapsulated Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
Related links:&lt;br /&gt;
* [[Behavior_Attachment | Behavior Attachment]] -- a general overview of the behavior attachment problem&lt;br /&gt;
* [[Component_Model_Methodology | Component Model Methodology]]&lt;br /&gt;
* [[Component_Model_Use_Cases | Component Model Use Cases]]&lt;br /&gt;
* [https://github.com/dglazkov/component-model Component Model Spec on Github]&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7087</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7087"/>
		<updated>2011-08-23T16:46:59Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the [https://github.com/dglazkov/component-model component model spec], which is being developed by applying a [[Component_Model_Methodology | defined methodology]].&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; introduces support for creating custom DOM elements. [[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery widgets, and encapsulated Like/+1 buttons.  Reflecting on the experience of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components, the Component Model formalizes the concept of loosely coupled, coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality goals of the Component Model resemble  the goals of [http://dev.w3.org/2006/xbl2/ XBL2]; unlike XBL2, the Component Model seeks to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7086</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7086"/>
		<updated>2011-08-23T16:40:58Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here&#039;s a good starting point for learning about the component model spec, which is currently [https://github.com/dglazkov/component-model under development] (also see periodically updating [http://dglazkov.github.com/component-model/ gh-pages]).&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Component Model&#039;&#039;&#039; supports the creation of custom DOM elements.&lt;br /&gt;
[[Component_Model_Use_Cases | Examples]] include layout managers, combinations of Dojo and jQuery&lt;br /&gt;
widgets, and encapsulated Like/+1 buttons.  Reflecting on the experience&lt;br /&gt;
of Mozilla&#039;s XBL  and Microsoft Internet Explorer&#039;s HTML components,&lt;br /&gt;
the Component Model formalizes the concept of loosely coupled, &lt;br /&gt;
coherent units of [[Behavior Attachment | behavior]]  in the [http://www.w3.org/wiki/Open_Web_Platform Web platform]. The functionality&lt;br /&gt;
goals of the Component Model resemble  the goals of XBL2; unlike XBL2&lt;br /&gt;
the Component Model seeks&lt;br /&gt;
to be more incremental and modular while leveraging and integrating with new technologies.&lt;br /&gt;
&lt;br /&gt;
=Properties=&lt;br /&gt;
&lt;br /&gt;
The component model aims to satisfy several key properties. These properties were extracted from the [[Component_Model_Use_Cases | use cases]]. This section explains component model basics by studying each property.&lt;br /&gt;
&lt;br /&gt;
==Extensibility==&lt;br /&gt;
&lt;br /&gt;
The component model enables creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here&#039;s how you would create a new sub-type of HTMLElement:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.&lt;br /&gt;
// 2) First parameter specifies the tagName of the element being registered and must be a string prefixed with &amp;quot;x-&amp;quot;.&lt;br /&gt;
Element.register(&amp;quot;x-layout-manager-panel&amp;quot;, LayoutManagerPanel);&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
var panel = new LayoutManagerPanel();&lt;br /&gt;
document.body.appendChild(panel);&lt;br /&gt;
// or&lt;br /&gt;
document.body.innerHTML = &amp;quot;&amp;lt;x-layout-manager-panel&amp;gt;&amp;lt;/x-layout-manager-panel&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt; instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
==Consistency==&lt;br /&gt;
&lt;br /&gt;
Because components are just DOM objects, they inherently share the same traversal and manipulation APIs, as defined by the [http://www.w3.org/TR/domcore/ DOM Core]. The authors of components can extend these APIs by adding custom methods and properties on DOM objects, using standard Javascript inheritance:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Widget.prototype = Object.create(HTMLElement.prototype, {&lt;br /&gt;
    update: {&lt;br /&gt;
        value: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
    value: {&lt;br /&gt;
        get: function() { /* ... */ },&lt;br /&gt;
        set: function() { /* ... */ }&lt;br /&gt;
    },&lt;br /&gt;
   // ...&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The common API surface and the ability to extend it serves as a natural API boundary for framework authors, enabling interoperability.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
&lt;br /&gt;
==Encapsulation==&lt;br /&gt;
Encapsulation refers to ability of the component to hide its implementation details and state from the document. To enable hiding of the implementation details, the component model provides a way to build a DOM tree that is not accessible from the document DOM tree, but is rendered as part of the document. This DOM tree, associated with the component is the [http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/ shadow DOM]. The boundary between the document DOM tree and shadow DOM tree provides complete encapsulation, and ensures that no information about the shadow DOM tree crosses this boundary. Additionally, the boundary serves as a convenient style application lever, giving the component a choice of letting (or not letting) document CSS affect the shadow DOM tree.&lt;br /&gt;
&lt;br /&gt;
Every DOM element instance may only have (or &#039;&#039;host&#039;&#039;) one shadow DOM tree. A shadow tree is instantiated by creating an instance of the &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; object, which takes a reference to the hosting element as a parameter. Attempting to create more than one instance for the same element throws an exception:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function LayoutManagerPanel() {&lt;br /&gt;
    HTMLElement.call(this);&lt;br /&gt;
    var shadow = new ShadowRoot(this);&lt;br /&gt;
    var shadow2 = new ShadowRoot(this); // throws an exception.&lt;br /&gt;
   // ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
&lt;br /&gt;
==Composability==&lt;br /&gt;
&lt;br /&gt;
Being DOM objects, components fit naturally into the document DOM tree and support all of its composition properties. In addition, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element allows controlling interaction between shadow and document DOM trees. A &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element specifies places where immediate document tree children of the component are rendered &#039;&#039;inside&#039;&#039; the shadow tree.&lt;br /&gt;
&lt;br /&gt;
There can be more than one &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element in the shadow tree. The &amp;lt;code&amp;gt;includes&amp;lt;/code&amp;gt; attribute provides a convenient way to sort element&#039;s children by CSS selector. For example, a &amp;lt;code&amp;gt;DockLayoutPanel&amp;lt;/code&amp;gt; component could be used like this in the document DOM tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Chauncey Gardiner.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Provided that its shadow DOM tree looks like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content includes=&amp;amp;quot;.west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;content&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;content includes=&amp;amp;quot;.south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;#shadow-root&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The document DOM tree children on of &amp;lt;code&amp;gt;x-dock-layout-panel&amp;lt;/code&amp;gt; will be rendered as if composed from this tree:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1 class=&amp;amp;quot;north&amp;amp;quot;&amp;amp;gt;On Gardens&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;ul class=&amp;amp;quot;west&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Automatic Gardens&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
                &amp;amp;lt;li&amp;amp;gt;Gardening on minefields&amp;amp;lt;/li&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/ul&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;east&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;p&amp;amp;gt;I love gardening.&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;div class=&amp;amp;quot;south&amp;amp;quot;&amp;amp;gt;Written by Avid Gardener.&amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/div&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/x-dock-layout-panel&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Desugaring==&lt;br /&gt;
The component model also explains pretty well how the native HTML elements are built and dispels some of the magic associated with the &amp;quot;DOM object vs. Javascript object&amp;quot; juxtaposition.&lt;br /&gt;
&lt;br /&gt;
Allowing DOM elements to participate in the Javascript inheritance chain makes DOM elements more approachable and easier to work with.&lt;br /&gt;
&lt;br /&gt;
Complex DOM elements that are rendered with more than one CSS box (and aren&#039;t specified in terms of CSS, like [http://dev.w3.org/csswg/css3-lists/ lists]) are just components that have shadow DOM. Coincidentally, this also explains why you can&#039;t add shadow DOM subtrees to &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;details&amp;lt;/code&amp;gt; elements -- their &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;s are claimed by &amp;lt;code&amp;gt;HTMLInputElement&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HTMLDetailsElement&amp;lt;/code&amp;gt; constructors, respectively.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
* [[#Content_Element | Content Element]]&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
Considering the way Web works, the component model must allow decoupling of the instantiation and the declaration of the components in order to provide reasonable performance characteristics. It&#039;s an unfortunate, but necessary requirement. In other words, we must be able to handle situations where a component instance is created before it is declared. Here&#039;s an simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// somewhere in view.js&lt;br /&gt;
...&lt;br /&gt;
document.body.innerHTML = &#039;&amp;lt;div class=&amp;quot;awesome&amp;quot;&amp;gt;&amp;lt;x-layout&amp;gt;&amp;lt;x-spring-panel&amp;gt;...&amp;lt;/x-spring-panel&amp;gt;&amp;lt;/x-layout&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
// somewhere in layout.js&lt;br /&gt;
Element.register(&#039;x-layout&#039;, Layout);&lt;br /&gt;
Element.register(&#039;x-spring-panel&#039;, SpringPanel);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, there is no room for error: &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt; &#039;&#039;must&#039;&#039; wait for &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; to load before executing. You can&#039;t load &amp;lt;code&amp;gt;layout.js&amp;lt;/code&amp;gt; lazily or in any different order, since it defines the components that are used in &amp;lt;code&amp;gt;view.js&amp;lt;/code&amp;gt;. Given that asynchronous, deferred or lazy-loading of script are all common performance techniques in today&#039;s Web, we must do better than block or throw an exception in such cases.&lt;br /&gt;
&lt;br /&gt;
The component model offers this solution:&lt;br /&gt;
&lt;br /&gt;
When an unknown DOM element with an &amp;quot;x-&amp;quot;-prefixed &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt; is encountered, we put a placeholder &amp;lt;code&amp;gt;HTMLUnknownElement&amp;lt;/code&amp;gt; instance in its place. As soon as the element is defined, all placeholder instances are replaced (think [http://www.w3.org/TR/domcore/#dom-node-replacechild replaceChild] with the extra work of transferring children, attributes, and children) with the new, proper DOM element.&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Registering_Elements | Registering Elements]]&lt;br /&gt;
&lt;br /&gt;
== Confinement ==&lt;br /&gt;
Confinement refers to the document protecting its implementation details and state from the component and can be viewed as the inverse of [[#Encapsulation | encapsulation]].&lt;br /&gt;
&lt;br /&gt;
Required Building Blocks:&lt;br /&gt;
* [[#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
&lt;br /&gt;
=Building Blocks=&lt;br /&gt;
&lt;br /&gt;
The component model is comprised of the following building blocks.&lt;br /&gt;
&lt;br /&gt;
==Shadow DOM==&lt;br /&gt;
&lt;br /&gt;
Any DOM element can host a shadow DOM subtree. The shadow DOM subtree originates at &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt;, which is coupled the hosting element at the time of its construction. You don&#039;t need any other building blocks in order to take advantage of the shadow DOM:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var element = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
var shadow = new ShadowRoot(element);&lt;br /&gt;
shadow.appendChild(document.createElement(&amp;quot;p&amp;quot;)).textContent = &amp;quot;weee!!&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; instance is a [http://www.w3.org/TR/domcore/#interface-node Node], and acts as the root of the element&#039;s shadow DOM subtree. The &amp;lt;code&amp;gt;ShadowRoot&amp;lt;/code&amp;gt; itself is never rendered, nor has styles. In this regard, it&#039;s similar to the [http://www.w3.org/TR/domcore/#interface-documentfragment DocumentFragment]. It has two properties:&lt;br /&gt;
* &amp;lt;code&amp;gt;applyAuthorSheets&amp;lt;/code&amp;gt;, which is either &#039;&#039;&#039;true&#039;&#039;&#039; (that is, apply author style sheets from the document), or &#039;&#039;&#039;false&#039;&#039;&#039; (don&#039;t);&lt;br /&gt;
* &amp;lt;code&amp;gt;shadowHost&amp;lt;/code&amp;gt;, which points to the hosting element.&lt;br /&gt;
&lt;br /&gt;
==Content Element==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; element is used with [[#Shadow_DOM | Shadow DOM]] and provides a mechanism for distributing hosting element&#039;s children inside of its shadow subtree. To preserve the [[#Encapsulation | encapsulation]] property, the &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; elements act as insertion points and do not leak any information about hosting element&#039;s children to the shadow DOM subtree or vise versa.&lt;br /&gt;
&lt;br /&gt;
==Constructable DOM Types==&lt;br /&gt;
The inability to construct DOM element using &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt; (with some exceptions) or use them in the prototype inheritance chain had confounded many Web developers since the beginning of DOM. This building block intends to rectify at least the latter by allowing &amp;lt;code&amp;gt;HTMLElement.call&amp;lt;/code&amp;gt; invocation and thus enabling creation of Javascript objects with DOM elements in the prototype chain.&lt;br /&gt;
&lt;br /&gt;
==Registering Elements==&lt;br /&gt;
Working in conjunction with  [[#Constructable_DOM_Types | Constructable DOM Types]], this building block makes the list of valid markup tag names extensible by exposing &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Supplemental]&lt;br /&gt;
interface Element {&lt;br /&gt;
    static void register(in String tagName, in Function constructor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to envisage a milder (though less elegant) version of element registration by keeping DOM element construction magical (thus decoupling it from [[#Constructable_DOM_Types | Constructable DOM Types]]) and making &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; use a callback, rather than &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; as parameter. The callback would be invoked with an already-constructed DOM object with the specified &amp;lt;code&amp;gt;tagName&amp;lt;/code&amp;gt;, leaving the work of setting up properties on this object to the callback.&lt;br /&gt;
&lt;br /&gt;
==Confinement Primitives==&lt;br /&gt;
&lt;br /&gt;
The API surface of the component model lends itself well to proper confinement. Here&#039;s an approach that could be used to provide it (very early brainstorming):&lt;br /&gt;
&lt;br /&gt;
* Confinement is not tied to the component model. Instead, it&#039;s a new twist on the method of loading scripts. A script could be loaded as usual or it could be &#039;&#039;confined&#039;&#039;, or loaded into its own context.&lt;br /&gt;
&lt;br /&gt;
* When confined, a script has its own global and document objects. These objects only reveal some safe limited subset of the actual document objects.  Think of it as a same-origin iframe with restrictions on document and window.&lt;br /&gt;
&lt;br /&gt;
* You can communicate with the main document using &amp;lt;code&amp;gt;window.postMessage&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* The confined document DOM tree is always empty. Attempting to insert into it throws exceptions.&lt;br /&gt;
&lt;br /&gt;
* ... except when you append to elements in shadow DOM. That&#039;s right, you can do &amp;lt;code&amp;gt;Element.register&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;new ShadowRoot&amp;lt;/code&amp;gt; in the confined document.&lt;br /&gt;
&lt;br /&gt;
* Whenever you register an element, it registers &#039;&#039;in the main document&#039;&#039; as well. Creating an instance of a component from an confined document produces a functional DOM element shell that proxies to the actual element in the confined document.&lt;br /&gt;
&lt;br /&gt;
Proposed API: introduce a new &amp;lt;code&amp;gt;confined&amp;lt;/code&amp;gt; attribute to the &amp;lt;code&amp;gt;script&amp;lt;/code&amp;gt; element. Presence of this attribute triggers loading scripts in the confined context.&lt;br /&gt;
&lt;br /&gt;
Confinement of script execution could be useful outside of the component model and also could be related to [https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html Content Security Policy].&lt;br /&gt;
&lt;br /&gt;
* [[Component_Model_Isolation_Brainstorming | Isolation Brainstorm]]&lt;br /&gt;
&lt;br /&gt;
=Comparison With Existing Specs and Implementations=&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a brief overview of existing similar specifications and implementations:&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/library/ms531018(v=vs.85).aspx HTML Components] is a [http://windows.microsoft.com/en-US/internet-explorer/products/ie/home Microsoft Internet Explorer]-specific method of creating custom DOM elements. Also see [http://www.w3.org/TR/NOTE-HTMLComponents HTML Components Note] (implemented in IE5+).&lt;br /&gt;
* [http://www.w3.org/TR/2001/NOTE-xbl-20010223/ XBL], currently implemented in Mozilla.&lt;br /&gt;
* [http://dev.w3.org/2006/xbl2/ XBL2], the ancestral spec of the Component Model, and a revision of XBL.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a handy overview of how each of these specs satisfies the component model [[#Properties | properties]]:&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | Spec/Implementation&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Extensibility | Extensibility]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Consistency | Consistency]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Encapsulation | Encapsulation]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Composability | Composability]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Desugaring | Desugaring]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Performance | Performance]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; width=&amp;quot;12%&amp;quot; | [[#Confinement | Confinement]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | HTML Components&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Components are magic, inextensible objects.&lt;br /&gt;
| &#039;&#039;&#039;Almost&#039;&#039;&#039;. Implementation provides ways to add properties, methods, events to element API, and the components are &#039;&#039;almost&#039;&#039; DOM elements. However, custom tags don&#039;t support all properties of a DOM element.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. There are some provisions for event encapsulation, nothing else.&lt;br /&gt;
| &#039;&#039;&#039;Not much&#039;&#039;&#039;. No provisions for handling document children vs. component-defined children.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The mechanism for extending bindings is entirely independent of DOM type or Javascript extensibility.&lt;br /&gt;
| &#039;&#039;&#039;Yes-ish&#039;&#039;&#039;. Bindings can override properties on the DOM element, although the mechanism is highly unnatural (XML declarations).&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;? Hard to say looking at TR note.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;. Some HTML elements in Gecko are implemented using it.&lt;br /&gt;
| &#039;&#039;&#039;Not sure&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | XBL2&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Same as XBL.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. Bindings are discouraged from establishing an API surface on a bound element.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;. The spec didn&#039;t intend to describe how native elements are built.&lt;br /&gt;
| &#039;&#039;&#039;Somewhat&#039;&#039;&#039;. The lifecycle of a binding is well-defined and initialization stages are well-decoupled. However, there is no way to build a binding imperatively without loading a binding document.&lt;br /&gt;
| &#039;&#039;&#039;No&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key differences between XBL2 and the Component Model are:&lt;br /&gt;
* The Component Model fully embraces the [[Behavior_Attachment#Behavior_Attachment_Methods | element behavior attachment]] by allowing creation of new types of DOM elements within a document. This is something Web Framework developers always wanted and repeatedly try to do with parallel object hierarchies. Eliminating ephemerality of the attachment simplifies and clarifies how things work conceptually -- there is no longer a place for &amp;quot;spooky action at a distance&amp;quot;, caused by a change of a random CSS selector or even removing an element from the tree.&lt;br /&gt;
* The Component Model is strongly biased toward reusing existing bits of the platform and well-established techniques instead of inventing new ones. For instance, instead of bindings inheritance, we rely on prototype inheritance. Instead of endeavoring to solve the incredibly complex, yet dubious problem of multiple bindings or shadow DOM trees, we simply suggest composition.&lt;br /&gt;
* The Component Model strives to add capabilities in layers (see [[#Building_Blocks | building blocks]]), each able to function on its own. The omnibus nature of XBL2 removes opportunities for layering, particularly as element identity, lifecycle, and scripting are concerned. Perhaps this could be repaired somehow, but Component Model solves these issues without further complicating an already large, difficult to understand spec.&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7085</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7085"/>
		<updated>2011-08-23T16:40:35Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] draft(s) for the building blocks;&lt;br /&gt;
# Cultivate implementation feedback:&lt;br /&gt;
#* Provide experimental implementation(s) for the building blocks;&lt;br /&gt;
#* Seek feedback from the use case audiences;&lt;br /&gt;
#* Incorporate feedback into specification.&lt;br /&gt;
# Write a test suite.&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
* The specification:&lt;br /&gt;
** is a complete set of requirements for all building blocks and corner cases, discovered during implementation;&lt;br /&gt;
* The test suite:&lt;br /&gt;
** provides coverage for each requirement in the specification.&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;br /&gt;
&lt;br /&gt;
=Implementation Sequence=&lt;br /&gt;
&lt;br /&gt;
Since the component model is composed of several building blocks, it is possible to implement it incrementally, gaining more insight with each step. Here&#039;s one possible sequence (tabulated against the [[Component_Model_Use_Cases | use cases]] and approximate percentage of satisfying them):&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | Step&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Layout_Manager | Layout Manager]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Widget_Mix-and-Match | Mix-and-Match]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Rendering_Form_Controls_with_SVG | SVG Controls]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Contacts_Widget | Contacts Widget]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Like.2F.2B1_Button | Like/+1 Button]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Media_Controls_For_The_Video_Element | Media Controls for the Video Element]]&lt;br /&gt;
! align=&amp;quot;left&amp;quot; | [[Component_Model_Use_Cases#Details.2FSummary_Elements | Details/Summary Element]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Shadow_DOM | Shadow DOM]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| 34%&lt;br /&gt;
| 100%&lt;br /&gt;
| 25%&lt;br /&gt;
| 100%&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Content_Element | Content Element]]&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 50%&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Constructable_DOM_Types | Constructable DOM Types]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Registering_Elements | Registering Elements]]&lt;br /&gt;
| 25%&lt;br /&gt;
| 50%&lt;br /&gt;
| 33%&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; style=&amp;quot;border-bottom: 1px solid LightGray;&amp;quot;&lt;br /&gt;
| [[Component_Model#Confinement_Primitives | Confinement Primitives]]&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 25%&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7084</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7084"/>
		<updated>2011-08-23T16:38:54Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] draft(s) for the building blocks;&lt;br /&gt;
# Cultivate implementation feedback:&lt;br /&gt;
#* Provide experimental implementation(s) for the building blocks;&lt;br /&gt;
#* Seek feedback from the use case audiences;&lt;br /&gt;
#* Incorporate feedback into specification.&lt;br /&gt;
# Write a test suite.&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
* The specification:&lt;br /&gt;
** is a complete set of requirements for all building blocks and corner cases, discovered during implementation;&lt;br /&gt;
* The test suite:&lt;br /&gt;
** provides coverage for each requirement in the specification.&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7083</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7083"/>
		<updated>2011-08-23T16:36:51Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] draft(s) for the building blocks;&lt;br /&gt;
# Provide implementation feedback:&lt;br /&gt;
#* Provide experimental implementations and seek feedback from use case audiences;&lt;br /&gt;
#* Write a test suite;&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
* The specification:&lt;br /&gt;
** is a complete set of requirements for all building blocks and corner cases, discovered during implementation;&lt;br /&gt;
* The test suite:&lt;br /&gt;
** provides coverage for each requirement in the specification.&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7082</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7082"/>
		<updated>2011-08-23T16:36:31Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] draft(s) using the building blocks;&lt;br /&gt;
# Provide implementation feedback:&lt;br /&gt;
#* Provide experimental implementations and seek feedback from use case audiences;&lt;br /&gt;
#* Write a test suite;&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
* The specification:&lt;br /&gt;
** is a complete set of requirements for all building blocks and corner cases, discovered during implementation;&lt;br /&gt;
* The test suite:&lt;br /&gt;
** provides coverage for each requirement in the specification.&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7081</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7081"/>
		<updated>2011-08-23T16:36:01Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Success criteria */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] based on the building blocks;&lt;br /&gt;
# Provide implementation feedback:&lt;br /&gt;
#* Provide experimental implementations and seek feedback from use case audiences;&lt;br /&gt;
#* Write a test suite;&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
* The specification:&lt;br /&gt;
** is a complete set of requirements for all building blocks and corner cases, discovered during implementation;&lt;br /&gt;
* The test suite:&lt;br /&gt;
** provides coverage for each requirement in the specification.&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7080</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7080"/>
		<updated>2011-08-23T16:31:22Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Write [https://github.com/dglazkov/component-model specification] based on the building blocks;&lt;br /&gt;
# Provide implementation feedback:&lt;br /&gt;
#* Provide experimental implementations and seek feedback from use case audiences;&lt;br /&gt;
#* Write a test suite;&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7079</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7079"/>
		<updated>2011-08-23T16:20:04Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]].&lt;br /&gt;
&lt;br /&gt;
=Approach=&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria=&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
&lt;br /&gt;
=Design Principles=&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7078</id>
		<title>Component Model Methodology</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Methodology&amp;diff=7078"/>
		<updated>2011-08-23T16:19:44Z</updated>

		<summary type="html">&lt;p&gt;Dglazkov: Created page with &amp;#039;Here are the guidelines for understanding the problem of and developing specification for the  Component Model  =Approach== # Capture requirements as [[Compo...&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are the guidelines for understanding the problem of and developing specification for the [[Component_Model | Component Model]]&lt;br /&gt;
&lt;br /&gt;
=Approach==&lt;br /&gt;
# Capture requirements as [[Component_Model_Use_Cases | use cases]];&lt;br /&gt;
# Study use cases and extract a set of [[Component_Model#Properties | desired properties]] for these use cases;&lt;br /&gt;
# Come with a design that satisfies all desired properties;&lt;br /&gt;
# Extrude [[Component_Model#Building_Blocks | building blocks]] out of the design;&lt;br /&gt;
# Iterate until [[#Success_Criteria | success criteria]] is reached.&lt;br /&gt;
&lt;br /&gt;
=Success criteria==&lt;br /&gt;
* The use cases:&lt;br /&gt;
** reasonably cover a set of component model needs on the Web.&lt;br /&gt;
* The properties:&lt;br /&gt;
** completely describe the set of use cases;&lt;br /&gt;
** are orthogonal to each other.&lt;br /&gt;
* The building blocks:&lt;br /&gt;
** satisfy all desired properties;&lt;br /&gt;
** follow the component model [[#Design_Priniciples | design principles]].&lt;br /&gt;
&lt;br /&gt;
=Design Principles==&lt;br /&gt;
* &#039;&#039;&#039;Reuse existing mechanisms&#039;&#039;&#039; as much as possible, gently extending them if necessary;&lt;br /&gt;
* Study popular patterns in existing Web frameworks and &#039;&#039;&#039;pave the cowpaths&#039;&#039;&#039; when appropriate;&lt;br /&gt;
* Encourage &#039;&#039;&#039;each building block to stand on its own&#039;&#039;&#039; merits.&lt;/div&gt;</summary>
		<author><name>Dglazkov</name></author>
	</entry>
</feed>