<?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=Morrita</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=Morrita"/>
	<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/wiki/Special:Contributions/Morrita"/>
	<updated>2026-04-23T23:37:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7529</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7529"/>
		<updated>2011-10-29T01:37:21Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.tags.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are executed over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrar.registering&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = document.tags.registering.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is invoked as a constructor.&lt;br /&gt;
&lt;br /&gt;
The creator callback is expected to have &amp;lt;tt&amp;gt;HTMLElement.prototype&amp;lt;/tt&amp;gt; in its prototype chain.&lt;br /&gt;
If it doesn&#039;t, agents set &amp;lt;tt&amp;gt;creator.prototype&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;HTMLElement.prototype&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { document.tags.bless(this); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.tags.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    document.tags.registering.creator = function() {&lt;br /&gt;
      document.tags.bless(this);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using class syntax, we could also write like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       constructor() { HTMLElement.call(this); }&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.tags.registering.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  constructor() { HTMLElement.call(this); }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
document.tags.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    document.tags.registering.creator = function() { document.tags.bless(this); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object, which is set as a &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.tags.registering.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup() {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.tags.registering.setup = function(shadow) {&lt;br /&gt;
       // Can setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=ConstructorOnly]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  void bless(any self);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The getter ===&lt;br /&gt;
&lt;br /&gt;
The getter returns HTMLRegistrationElement whose &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; attribute&lt;br /&gt;
matches &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; parameter. unless returns null.&lt;br /&gt;
&lt;br /&gt;
The getter can be used like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var newCommentElement = document.elements[&amp;quot;x-comment&amp;quot;].create();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;register&amp;lt;/tt&amp;gt; method ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrar#register&amp;lt;/tt&amp;gt; method is a shortcut for &lt;br /&gt;
following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = name;&lt;br /&gt;
element.creator = creator;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;bless&amp;lt;/tt&amp;gt; method ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;registering&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
For each &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; block which is a child of &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; is executed,&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistar#registering&amp;lt;/tt&amp;gt; is set to the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7518</id>
		<title>Component Model</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model&amp;diff=7518"/>
		<updated>2011-10-28T19:48:00Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &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;
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;
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;
* [[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;
Discussion 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_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;
&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>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7517</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7517"/>
		<updated>2011-10-28T19:33:20Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading an External HTML Resource =&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition also can be done in an external, separate HTML resource.&lt;br /&gt;
Author can define a set of elements inside the external HTML and use it in different HTML pages. &lt;br /&gt;
&lt;br /&gt;
Effective markup vocabulary for the external HTML is limited.&lt;br /&gt;
Agents only recognize the first &amp;lt;tt&amp;gt;head element&amp;lt;/tt&amp;gt; and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The host document ==&lt;br /&gt;
&lt;br /&gt;
The document which hosts an external HTML file is called a &amp;quot;host document&amp;quot;.&lt;br /&gt;
Any HTML document can host be a host document. &lt;br /&gt;
&lt;br /&gt;
If author add a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt; to a apge, &lt;br /&gt;
the page hosts the linked HTML resource.&lt;br /&gt;
&lt;br /&gt;
In this example, the document hosts &amp;lt;tt&amp;gt;comment.html&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute ==&lt;br /&gt;
&lt;br /&gt;
Author can add the &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute to confine the component definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Shared Hosting =&lt;br /&gt;
&lt;br /&gt;
If an author hosts an external HTML without specifying &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute,&lt;br /&gt;
the HTML is hosted as a shared resource. &lt;br /&gt;
That means, agents insert &amp;lt;tt&amp;gt;head&amp;lt;/tt&amp;gt; children of the hosted document&lt;br /&gt;
into the host document&#039;s &amp;lt;tt&amp;gt;head&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Each script execution inside hosted HTML shares the global object with its host document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, the host document eventually has an &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element named &amp;lt;tt&amp;gt;x-comment&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- comment.html --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- host document --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var shouldNotNull = document.querySelector(&amp;quot;element[name=x-comment]&amp;quot;);&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Confined Hosting =&lt;br /&gt;
&lt;br /&gt;
If an author hosts an external HTML without specifying &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute,&lt;br /&gt;
the HTML is hosted as a confined resource. &lt;br /&gt;
&lt;br /&gt;
A confined resource has its document object. Any scripts inside the confined resource &lt;br /&gt;
are run on its own global object. &lt;br /&gt;
&lt;br /&gt;
Conceptually, a confined resource is similar to a document in a cross-domain frame.&lt;br /&gt;
For example, the script on the confined resource can make a XMLHttpRequest to its own domain, instead of the host domain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- comment.html --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;script&amp;gt;&lt;br /&gt;
         console.log(document.location.toString()); // prints the url of comment.html &lt;br /&gt;
       &amp;lt;script&amp;gt;&lt;br /&gt;
    &amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- host document --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Registered Elements in a Confined Resource ==&lt;br /&gt;
&lt;br /&gt;
The host document recognize an element name which is registered in the hosting confined documents, not only&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7516</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7516"/>
		<updated>2011-10-28T18:21:52Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading an External HTML Resource =&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition also can be done in an external, separate HTML resource.&lt;br /&gt;
Author can define a set of elements inside the external HTML and use it in different HTML pages. &lt;br /&gt;
&lt;br /&gt;
Effective markup vocabulary for the external HTML is limited.&lt;br /&gt;
Agents only recognize the first &amp;lt;tt&amp;gt;head element&amp;lt;/tt&amp;gt; and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The host document ==&lt;br /&gt;
&lt;br /&gt;
The document which hosts an external HTML file is called a &amp;quot;host document&amp;quot;.&lt;br /&gt;
Any HTML document can host be a host document. &lt;br /&gt;
&lt;br /&gt;
If author add a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt; to a apge, &lt;br /&gt;
the page hosts the linked HTML resource.&lt;br /&gt;
&lt;br /&gt;
In this example, the document hosts &amp;lt;tt&amp;gt;comment.html&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute ==&lt;br /&gt;
&lt;br /&gt;
Author can add the &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute to confine the component definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Shared Hosting =&lt;br /&gt;
&lt;br /&gt;
If an author hosts an external HTML without specifying &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute,&lt;br /&gt;
the HTML is hosted as a shared resource. &lt;br /&gt;
That means, agents insert &amp;lt;tt&amp;gt;head&amp;lt;/tt&amp;gt; children of the hosted document&lt;br /&gt;
into the host document&#039;s &amp;lt;tt&amp;gt;head&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Each script execution inside hosted HTML shares the global object with its host document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, the host document eventually has an &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element named &amp;lt;tt&amp;gt;x-comment&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- comment.html --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- host document --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var shouldNotNull = document.querySelector(&amp;quot;element[name=x-comment]&amp;quot;);&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Confined Hosting =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If an author hosts an external HTML without specifying &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute,&lt;br /&gt;
the HTML is hosted as a confined resource. &lt;br /&gt;
&lt;br /&gt;
A confined resource has its document object. ANy scripts inside the confined resource &lt;br /&gt;
are run on its own global object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- comment.html --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;script&amp;gt;&lt;br /&gt;
         console.log(document.location.toString()); // prints the url of comment.html &lt;br /&gt;
       &amp;lt;script&amp;gt;&lt;br /&gt;
    &amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- host document --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7515</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7515"/>
		<updated>2011-10-28T17:48:29Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading an External HTML Resource =&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition also can be done in an external, separate HTML resource.&lt;br /&gt;
Author can define a set of elements inside the external HTML and use it in different HTML pages. &lt;br /&gt;
&lt;br /&gt;
Effective markup vocabulary for the external HTML is limited.&lt;br /&gt;
Agents only recognize the first &amp;lt;tt&amp;gt;head element&amp;lt;/tt&amp;gt; and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The host document ==&lt;br /&gt;
&lt;br /&gt;
The document which hosts an external HTML file is called a &amp;quot;host document&amp;quot;.&lt;br /&gt;
Any HTML document can host be a host document. &lt;br /&gt;
&lt;br /&gt;
If author add a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt; to a apge, &lt;br /&gt;
the page hosts the linked HTML resource.&lt;br /&gt;
&lt;br /&gt;
In this example, the document hosts &amp;lt;tt&amp;gt;comment.html&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute ==&lt;br /&gt;
&lt;br /&gt;
Author can add the &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute to confine the component definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Shared Hosting =&lt;br /&gt;
&lt;br /&gt;
If an author hosts an external HTML without specifying &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute,&lt;br /&gt;
the HTML is hosted as a shared resource. &lt;br /&gt;
That means, agents insert &amp;lt;tt&amp;gt;head&amp;lt;/tt&amp;gt; children of the hosted document&lt;br /&gt;
into the host document&#039;s &amp;lt;tt&amp;gt;head&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Each script execution inside hosted HTML shares the global object with its host document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, the host document eventually has an &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element named &amp;lt;tt&amp;gt;x-comment&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- comment.html --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- host document --&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var shouldNotNull = document.querySelector(&amp;quot;element[name=x-comment]&amp;quot;);&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7514</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7514"/>
		<updated>2011-10-28T17:31:54Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Loading an External HTML Resource */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading an External HTML Resource =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize the first &amp;lt;tt&amp;gt;head element&amp;lt;/tt&amp;gt; and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute ==&lt;br /&gt;
&lt;br /&gt;
Author can add the &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute to confine the component definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7513</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7513"/>
		<updated>2011-10-28T17:31:22Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Loading a HTML Resource */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading an External HTML Resource =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize the first head element and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute ==&lt;br /&gt;
&lt;br /&gt;
Author can add the &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute to confine the component definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7512</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7512"/>
		<updated>2011-10-27T22:49:34Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Loading a HTML Resource */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading a HTML Resource =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize the first head element and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute ==&lt;br /&gt;
&lt;br /&gt;
Author can add the &amp;lt;tt&amp;gt;confined&amp;lt;/tt&amp;gt; attribute to confine the component definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7511</id>
		<title>Component Model Strawman: Declarative Syntax</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7511"/>
		<updated>2011-10-27T21:12:42Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Shadow DOM Template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Element Registration =&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Element_Registration]]&lt;br /&gt;
&lt;br /&gt;
= Isolation =&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Isolation]]&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7510</id>
		<title>Component Model Strawman: Declarative Syntax</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7510"/>
		<updated>2011-10-27T21:12:25Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Isolation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Element Registration =&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Element_Registration]]&lt;br /&gt;
&lt;br /&gt;
= Shadow DOM Template =&lt;br /&gt;
&lt;br /&gt;
An initial shape of new shadow tree can be defined using a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; is instantiated through&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;ShadowRoot&amp;lt;/tt&amp;gt; constructor and&lt;br /&gt;
* &amp;lt;tt&amp;gt;shadow-template&amp;lt;/tt&amp;gt; CSS property.&lt;br /&gt;
&lt;br /&gt;
== The ShadowRoot constructor ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;ShadowRoot&amp;lt;/tt&amp;gt; constructor accepts a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element to instantiate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ..&lt;br /&gt;
  this.shadow = new ShadowRoot(this, document.getElementById(“comment-template”));&lt;br /&gt;
  ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The shadow-template CSS property  (brainstorming) ==&lt;br /&gt;
&lt;br /&gt;
The template for shadow root also can be applied using CSS property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.comment {&lt;br /&gt;
  shadow-template: url(&#039;#comment-template&#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that imperatively-applied shadows always supersede shadows from the styling.&lt;br /&gt;
Also, there is no way to access style-originated shadows from the scripting environment.&lt;br /&gt;
&lt;br /&gt;
== The Instantiation Event and Scripting ==&lt;br /&gt;
&lt;br /&gt;
Even though the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; can be used to define an extra visual representation for an element,&lt;br /&gt;
It would be useful if author can attach a script for the template-generated shadow tree.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element generates an &amp;lt;tt&amp;gt;instantiation&amp;lt;/tt&amp;gt; event for &lt;br /&gt;
each template instantiation. Authors can listen it to setup event handlers for&lt;br /&gt;
generated elements by the template. The event doesn&#039;t bubble, and it isn&#039;t cancelable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
  &amp;lt;script&amp;gt;&lt;br /&gt;
  var e = document.getElementById(&amp;quot;comment-template&amp;quot;);&lt;br /&gt;
  e.addEventListener(&amp;quot;instantiation&amp;quot;, function(evt) {&lt;br /&gt;
    evt.root.querySelector(&amp;quot;div&amp;quot;).addEventListener(&amp;quot;click&amp;quot;, function(evt) { ... });&lt;br /&gt;
  });&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element also allows a &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element as a child,&lt;br /&gt;
whose script block can access &amp;lt;tt&amp;gt;HTMLTemplateElement.current&amp;lt;/tt&amp;gt; to refer the enclosing &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLTemplateElement.current.addEventListener(&amp;quot;instantiation&amp;quot;, function(evt) {&lt;br /&gt;
      evt.root.querySelector(&amp;quot;div&amp;quot;).addEventListener(&amp;quot;click&amp;quot;, function(evt) { ... });&lt;br /&gt;
    });&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Isolation =&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Isolation]]&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7509</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7509"/>
		<updated>2011-10-27T20:46:50Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Loading a HTML Resource */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading a HTML Resource =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize the first head element and its descendant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7508</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7508"/>
		<updated>2011-10-27T20:44:04Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Loading a HTML Resource as a Component Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading a HTML Resource =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize a head element as a child of the root element when the HTML document is loaded as required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7507</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7507"/>
		<updated>2011-10-27T20:43:34Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
= Loading a HTML Resource as a Component Definition =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize a head element as a child of the root element when the HTML document is loaded as required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7506</id>
		<title>Component Model Strawman: Declarative Syntax</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7506"/>
		<updated>2011-10-27T20:43:29Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Standalone Form */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Element Registration =&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Element_Registration]]&lt;br /&gt;
&lt;br /&gt;
= Shadow DOM Template =&lt;br /&gt;
&lt;br /&gt;
An initial shape of new shadow tree can be defined using a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; is instantiated through&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;ShadowRoot&amp;lt;/tt&amp;gt; constructor and&lt;br /&gt;
* &amp;lt;tt&amp;gt;shadow-template&amp;lt;/tt&amp;gt; CSS property.&lt;br /&gt;
&lt;br /&gt;
== The ShadowRoot constructor ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;ShadowRoot&amp;lt;/tt&amp;gt; constructor accepts a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element to instantiate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ..&lt;br /&gt;
  this.shadow = new ShadowRoot(this, document.getElementById(“comment-template”));&lt;br /&gt;
  ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The shadow-template CSS property  (brainstorming) ==&lt;br /&gt;
&lt;br /&gt;
The template for shadow root also can be applied using CSS property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.comment {&lt;br /&gt;
  shadow-template: url(&#039;#comment-template&#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that imperatively-applied shadows always supersede shadows from the styling.&lt;br /&gt;
Also, there is no way to access style-originated shadows from the scripting environment.&lt;br /&gt;
&lt;br /&gt;
== The Instantiation Event and Scripting ==&lt;br /&gt;
&lt;br /&gt;
Even though the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; can be used to define an extra visual representation for an element,&lt;br /&gt;
It would be useful if author can attach a script for the template-generated shadow tree.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element generates an &amp;lt;tt&amp;gt;instantiation&amp;lt;/tt&amp;gt; event for &lt;br /&gt;
each template instantiation. Authors can listen it to setup event handlers for&lt;br /&gt;
generated elements by the template. The event doesn&#039;t bubble, and it isn&#039;t cancelable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
  &amp;lt;script&amp;gt;&lt;br /&gt;
  var e = document.getElementById(&amp;quot;comment-template&amp;quot;);&lt;br /&gt;
  e.addEventListener(&amp;quot;instantiation&amp;quot;, function(evt) {&lt;br /&gt;
    evt.root.querySelector(&amp;quot;div&amp;quot;).addEventListener(&amp;quot;click&amp;quot;, function(evt) { ... });&lt;br /&gt;
  });&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element also allows a &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element as a child,&lt;br /&gt;
whose script block can access &amp;lt;tt&amp;gt;HTMLTemplateElement.current&amp;lt;/tt&amp;gt; to refer the enclosing &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLTemplateElement.current.addEventListener(&amp;quot;instantiation&amp;quot;, function(evt) {&lt;br /&gt;
      evt.root.querySelector(&amp;quot;div&amp;quot;).addEventListener(&amp;quot;click&amp;quot;, function(evt) { ... });&lt;br /&gt;
    });&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Isolation =&lt;br /&gt;
&lt;br /&gt;
== Standalone Form ==&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Isolation]]&lt;br /&gt;
&lt;br /&gt;
== Shared definition ==&lt;br /&gt;
&lt;br /&gt;
In the default, these definitions are coming into the host document.&lt;br /&gt;
That means a providing HTML doesn’t have its own document nor the global object. Agents use these of the host document. &lt;br /&gt;
&lt;br /&gt;
== Isolated definition ==&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute contains the term &amp;lt;tt&amp;gt;isolate&amp;lt;/tt&amp;gt;, the linked HTML is loaded as a separate document object.&lt;br /&gt;
The script inside the document is given a separate global object. &lt;br /&gt;
&lt;br /&gt;
For the host document, there is no way to access the loaded document directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[User:Rolandsteiner|RolandSteiner]] Should we make &amp;lt;tt&amp;gt;isolate&amp;lt;/tt&amp;gt; an attribute on &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; rather than a &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; value? As Dimitri mentioned, this could be useful in general and would allow us to branch it off into a separate spec.&lt;br /&gt;
&lt;br /&gt;
[[User:Morrita|Morrita]] Any declarative syntax is a part of other spec. This is cross-cutting view of multiple proposals. moved out confined declaration to standalone attribute. I have no idea how this works for other types of linked resources though.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7505</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7505"/>
		<updated>2011-10-27T19:34:57Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The script element */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are executed over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrar.registering&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = document.elements.registering.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The getter ===&lt;br /&gt;
&lt;br /&gt;
The getter returns HTMLRegistrationElement whose &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; attribute&lt;br /&gt;
matches &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; parameter. unless returns null.&lt;br /&gt;
&lt;br /&gt;
The getter can be used like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var newCommentElement = document.elements[&amp;quot;x-comment&amp;quot;].create();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;register&amp;lt;/tt&amp;gt; method ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrar#register&amp;lt;/tt&amp;gt; method is a shortcut for &lt;br /&gt;
following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = name;&lt;br /&gt;
element.creator = creator;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;registering&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
For each &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; block which is a child of &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; is executed,&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistar#registering&amp;lt;/tt&amp;gt; is set to the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7504</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7504"/>
		<updated>2011-10-27T19:29:33Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* HTMLRegistrar and document.elements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrar.registering&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = document.elements.registering.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The getter ===&lt;br /&gt;
&lt;br /&gt;
The getter returns HTMLRegistrationElement whose &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; attribute&lt;br /&gt;
matches &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; parameter. unless returns null.&lt;br /&gt;
&lt;br /&gt;
The getter can be used like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var newCommentElement = document.elements[&amp;quot;x-comment&amp;quot;].create();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;register&amp;lt;/tt&amp;gt; method ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrar#register&amp;lt;/tt&amp;gt; method is a shortcut for &lt;br /&gt;
following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = name;&lt;br /&gt;
element.creator = creator;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;registering&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
For each &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; block which is a child of &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; is executed,&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistar#registering&amp;lt;/tt&amp;gt; is set to the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7503</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7503"/>
		<updated>2011-10-27T19:21:38Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The creator callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrar.registering&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = document.elements.registering.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7502</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7502"/>
		<updated>2011-10-27T19:21:10Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The script element */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrar.registering&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = document.elements.registering.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7501</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7501"/>
		<updated>2011-10-27T19:19:44Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The element element and HTMLRegistrationElement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    document.elements.registering.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
document.elements.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    document.elements.registering.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     document.elements.registering.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7500</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7500"/>
		<updated>2011-10-27T19:17:01Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* HTMLRegistrar and document.elements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLRegistrationCreatorCallback creator);&lt;br /&gt;
  readonly attribute HTMLRegistrationElement registering;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7499</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7499"/>
		<updated>2011-10-27T19:15:43Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* HTMLRegistrar and document.elements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;br /&gt;
It provides a keyed-collection like access to each registered element.&lt;br /&gt;
It also provides some utility method which helps idiomatic element registration and its use.&lt;br /&gt;
&lt;br /&gt;
The object exists per document, and is accessible through the &amp;lt;tt&amp;gt;Document#elements&amp;lt;/tt&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[NoInterfaceObject]&lt;br /&gt;
interface HTMLRegistrar {&lt;br /&gt;
  getter HTMLRegistrationElement (DOMString name);&lt;br /&gt;
  void register(DOMString name, [Optional] HTMLElementRegisrationCreateCallback callback);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7498</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7498"/>
		<updated>2011-10-27T19:10:38Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* HTMLRegistrationElement interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
  HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrationElement#create()&amp;lt;/tt&amp;gt; instantiates an registered element instance.&lt;br /&gt;
&lt;br /&gt;
 * TODO: The parameters of create() should match to the standard element constructor parameter list.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7497</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7497"/>
		<updated>2011-10-27T19:07:25Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.creator = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.creator = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;creator&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;creator&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    creator=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; creator=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreatorCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreatorCallback creator;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;document.elements&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLRegistrar&amp;lt;/tt&amp;gt; is an object oriented way to access registered element definitions.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7496</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7496"/>
		<updated>2011-10-27T18:59:20Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute ===&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
Once the attribute value is set, that is invoked as an expression.&lt;br /&gt;
The expression should return a function object. &lt;br /&gt;
And the returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is especially useful if you have a class-style constructor. It can be given like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7495</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7495"/>
		<updated>2011-10-27T18:53:32Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7494</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7494"/>
		<updated>2011-10-27T01:17:40Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(element.name);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7493</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7493"/>
		<updated>2011-10-27T01:16:56Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() {&lt;br /&gt;
      return new HTMLElement(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; &lt;br /&gt;
    create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7492</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7492"/>
		<updated>2011-10-27T01:12:02Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7491</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7491"/>
		<updated>2011-10-27T01:11:17Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Shadow Tree construction and the template element */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree Construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7490</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7490"/>
		<updated>2011-10-27T01:10:24Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The setup callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So if we define &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; for the registered element, it will be called &lt;br /&gt;
as a &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
      setup(shadow) {&lt;br /&gt;
        // should be called.&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7489</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7489"/>
		<updated>2011-10-27T01:07:20Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The setup callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this);&lt;br /&gt;
  ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7488</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7488"/>
		<updated>2011-10-27T01:07:03Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The setup callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() {&lt;br /&gt;
  this.shadow = new ShadowRoot(this); ...;&lt;br /&gt;
};&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7487</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7487"/>
		<updated>2011-10-27T01:03:11Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Shadow Tree construction and the template element */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7486</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7486"/>
		<updated>2011-10-27T01:02:19Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* HTMLRegistrationElement interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7485</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7485"/>
		<updated>2011-10-27T01:01:40Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. The attribute value is invoked as an expression and &lt;br /&gt;
should return a function object. &lt;br /&gt;
The returned function object is set to  &amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; property of the &lt;br /&gt;
&amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&lt;br /&gt;
                 create=&amp;quot;function() { new HTMLElement(&#039;x-comment&#039;); }&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7483</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7483"/>
		<updated>2011-10-27T00:07:50Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The setup callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;new HTMLElement(&#039;x-comment&#039;)&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     HTMLRegistrationElement.current.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7482</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7482"/>
		<updated>2011-10-27T00:02:54Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;new HTMLElement(&#039;x-comment&#039;)&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 3 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7481</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7481"/>
		<updated>2011-10-27T00:02:22Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback can also be set by the &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; attribute on &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;new HTMLElement(&#039;x-comment&#039;)&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following three markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot; create=&amp;quot;Comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    HTMLRegistrationElement.current.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7480</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7480"/>
		<updated>2011-10-26T23:47:30Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The script element */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are evaluated over a global object.&lt;br /&gt;
Before the evaluation, &amp;lt;tt&amp;gt;HTMLRegistrationElement.current&amp;lt;/tt&amp;gt; is set to the&lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = HTMLRegistrationElement.current.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7479</id>
		<title>Component Model Strawman: Isolation</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Isolation&amp;diff=7479"/>
		<updated>2011-10-26T23:43:07Z</updated>

		<summary type="html">&lt;p&gt;Morrita: Replaced content with &amp;#039;Stub.&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Stub.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7476</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7476"/>
		<updated>2011-10-26T20:28:52Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Shadow Tree construction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction and the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7475</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7475"/>
		<updated>2011-10-26T20:26:57Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration mechanism.&lt;br /&gt;
page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7474</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7474"/>
		<updated>2011-10-26T20:25:39Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7473</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7473"/>
		<updated>2011-10-26T20:25:11Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element name=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7472</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7472"/>
		<updated>2011-10-26T20:20:40Z</updated>

		<summary type="html">&lt;p&gt;Morrita: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shadow Tree construction ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element helps to construct a shadow tree for newly created elements.&lt;br /&gt;
If &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element has a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element as its child, &lt;br /&gt;
The agent creates shadow tree from the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element before invoking the &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;&lt;br /&gt;
callback, then invokes it with the shadow root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;template&amp;gt;&lt;br /&gt;
      &amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/template&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function(shadow) {&lt;br /&gt;
       // setup using the shadow instance.&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(ShadowRoot shadow = null);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7468</id>
		<title>Component Model Strawman: Declarative Syntax</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Declarative_Syntax&amp;diff=7468"/>
		<updated>2011-10-26T20:09:04Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* Element Registration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Element Registration =&lt;br /&gt;
&lt;br /&gt;
Moved to [[Component_Model_Strawman:_Element_Registration]]&lt;br /&gt;
&lt;br /&gt;
= Shadow DOM Template =&lt;br /&gt;
&lt;br /&gt;
An initial shape of new shadow tree can be defined using a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; is instantiated through&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;ShadowRoot&amp;lt;/tt&amp;gt; constructor and&lt;br /&gt;
* &amp;lt;tt&amp;gt;shadow-template&amp;lt;/tt&amp;gt; CSS property.&lt;br /&gt;
&lt;br /&gt;
== The ShadowRoot constructor ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;ShadowRoot&amp;lt;/tt&amp;gt; constructor accepts a &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element to instantiate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ..&lt;br /&gt;
  this.shadow = new ShadowRoot(this, document.getElementById(“comment-template”));&lt;br /&gt;
  ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The shadow-template CSS property  (brainstorming) ==&lt;br /&gt;
&lt;br /&gt;
The template for shadow root also can be applied using CSS property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.comment {&lt;br /&gt;
  shadow-template: url(&#039;#comment-template&#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that imperatively-applied shadows always supersede shadows from the styling.&lt;br /&gt;
Also, there is no way to access style-originated shadows from the scripting environment.&lt;br /&gt;
&lt;br /&gt;
== The Instantiation Event and Scripting ==&lt;br /&gt;
&lt;br /&gt;
Even though the &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; can be used to define an extra visual representation for an element,&lt;br /&gt;
It would be useful if author can attach a script for the template-generated shadow tree.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element generates an &amp;lt;tt&amp;gt;instantiation&amp;lt;/tt&amp;gt; event for &lt;br /&gt;
each template instantiation. Authors can listen it to setup event handlers for&lt;br /&gt;
generated elements by the template. The event doesn&#039;t bubble, and it isn&#039;t cancelable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
  &amp;lt;script&amp;gt;&lt;br /&gt;
  var e = document.getElementById(&amp;quot;comment-template&amp;quot;);&lt;br /&gt;
  e.addEventListener(&amp;quot;instantiation&amp;quot;, function(evt) {&lt;br /&gt;
    evt.root.querySelector(&amp;quot;div&amp;quot;).addEventListener(&amp;quot;click&amp;quot;, function(evt) { ... });&lt;br /&gt;
  });&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element also allows a &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element as a child,&lt;br /&gt;
whose script block can access &amp;lt;tt&amp;gt;HTMLTemplateElement.current&amp;lt;/tt&amp;gt; to refer the enclosing &amp;lt;tt&amp;gt;template&amp;lt;/tt&amp;gt; element. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;template id=”comment-template”&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&amp;lt;content&amp;gt;&amp;lt;/content&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    HTMLTemplateElement.current.addEventListener(&amp;quot;instantiation&amp;quot;, function(evt) {&lt;br /&gt;
      evt.root.querySelector(&amp;quot;div&amp;quot;).addEventListener(&amp;quot;click&amp;quot;, function(evt) { ... });&lt;br /&gt;
    });&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Isolation =&lt;br /&gt;
&lt;br /&gt;
== Standalone Form ==&lt;br /&gt;
&lt;br /&gt;
The element registration and template definition are also done in a separate HTML.&lt;br /&gt;
Effective markup vocabulary for the defining HTML is limited.&lt;br /&gt;
Agents only recognize a head element as a child of the root element when the HTML document is loaded as required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;..&amp;lt;/element&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The host element can load the html with element definition using a &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; element with its &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute set to &amp;lt;tt&amp;gt;component&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standalone definition can be done by a script file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/javascript” href=&amp;quot;comment.js&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is equivalent to linking to a HTML file of like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html provide&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;script type=”text/javascript” src=&amp;quot;comment.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Shared definition ==&lt;br /&gt;
&lt;br /&gt;
In the default, these definitions are coming into the host document.&lt;br /&gt;
That means a providing HTML doesn’t have its own document nor the global object. Agents use these of the host document. &lt;br /&gt;
&lt;br /&gt;
== Isolated definition ==&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; attribute contains the term &amp;lt;tt&amp;gt;isolate&amp;lt;/tt&amp;gt;, the linked HTML is loaded as a separate document object.&lt;br /&gt;
The script inside the document is given a separate global object. &lt;br /&gt;
&lt;br /&gt;
For the host document, there is no way to access the loaded document directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=”component” type=”text/html” href=&amp;quot;comment.html&amp;quot; confined&amp;gt;&lt;br /&gt;
  &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[User:Rolandsteiner|RolandSteiner]] Should we make &amp;lt;tt&amp;gt;isolate&amp;lt;/tt&amp;gt; an attribute on &amp;lt;tt&amp;gt;link&amp;lt;/tt&amp;gt; rather than a &amp;lt;tt&amp;gt;rel&amp;lt;/tt&amp;gt; value? As Dimitri mentioned, this could be useful in general and would allow us to branch it off into a separate spec.&lt;br /&gt;
&lt;br /&gt;
[[User:Morrita|Morrita]] Any declarative syntax is a part of other spec. This is cross-cutting view of multiple proposals. moved out confined declaration to standalone attribute. I have no idea how this works for other types of linked resources though.&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7464</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7464"/>
		<updated>2011-10-26T20:07:13Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The element element and HTMLRegistrationElement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Styling ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element also allows the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element as its children.&lt;br /&gt;
The style given by the element is a part of document stylesheet. &lt;br /&gt;
Authors can use the &amp;lt;tt&amp;gt;style&amp;lt;/tt&amp;gt; element to provide the style for the registering element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;style&amp;gt;&lt;br /&gt;
    x-comment {&lt;br /&gt;
       color: gray;&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(HTMLElement);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7460</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7460"/>
		<updated>2011-10-26T20:03:25Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The element element and HTMLRegistrationElement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; element ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element allows &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; elements in its children.&lt;br /&gt;
These script blocks are invoked as a function, whose receiver(&amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;) is bound to  &lt;br /&gt;
enclosing &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element. These script blocks can be used for providing &lt;br /&gt;
lifecycle callback definitions for the registering element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     var shouldBeXComment = this.name;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ===&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(HTMLElement);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7458</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7458"/>
		<updated>2011-10-26T19:53:56Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The create callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two markup and one imperative examples have same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 1 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup 2 --&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative&lt;br /&gt;
class Comment : HTMLElement {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
HTMLRegistrationElement(&amp;quot;x-comment&amp;quot;, Comment);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ==&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(HTMLElement);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7457</id>
		<title>Component Model Strawman: Element Registration</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=Component_Model_Strawman:_Element_Registration&amp;diff=7457"/>
		<updated>2011-10-26T19:51:30Z</updated>

		<summary type="html">&lt;p&gt;Morrita: /* The setup callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
With the Element Registration. page authors can tell new element names and its behavior to agents.&lt;br /&gt;
&lt;br /&gt;
= The &amp;lt;tt&amp;gt;element&amp;lt;/tt&amp;gt; element and &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; represents an author-registered element definition.&lt;br /&gt;
&lt;br /&gt;
Here is the simplest example which registeres an element named &amp;quot;x-comment&amp;quot; whose instance implements&lt;br /&gt;
&amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;HTMLRegistrationElement&amp;lt;/tt&amp;gt; provide a pair of lifecycle callbacks&lt;br /&gt;
for the element instance creation including the tree construction.&lt;br /&gt;
&lt;br /&gt;
The first callback, &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; is invoked when an agent need a new element instance of the registered element. &lt;br /&gt;
&amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback should return new element instance which matches the registered element specification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
element.name = &amp;quot;x-comment&amp;quot;;&lt;br /&gt;
element.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
document.head.appendChild(element);&lt;br /&gt;
// Shorter form.&lt;br /&gt;
HTMLRegistrationElement.register(&amp;quot;x-comment&amp;quot;, function() { ... });&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    this.create = function() { return new HTMLElement(&amp;quot;x-comment&amp;quot;); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the callback function has &amp;lt;tt&amp;gt;HTMLElement&amp;lt;/tt&amp;gt; in its prototype chain,&lt;br /&gt;
it is invoked as a constructor. Thus following two example has same meaning.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = Comment;&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    class Comment : HTMLElement {&lt;br /&gt;
       ....&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    this.create = function() { return new Comment(); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;create&amp;lt;/tt&amp;gt; callback is given, its default behavior is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
    var element = this;&lt;br /&gt;
    this.create = function() { return new HTMLElement(element.name); };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback ==&lt;br /&gt;
&lt;br /&gt;
The second lifecycle callback, &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; is called after an instance creation.&lt;br /&gt;
If the instance is created by the agent&#039;s tree construction, it will be called as a part of the &amp;quot;close&amp;quot; phase.&lt;br /&gt;
On &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt;, the attributes and child elements for the element are already set by the agent.&lt;br /&gt;
So this callback is useful for building its visual like the shadow tree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Imperative API&lt;br /&gt;
var element = document.createElement(&amp;quot;element&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
element.setup = function() { this.shadow = new ShadowRoot(this); ...; };&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Markup API --&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;element for=&amp;quot;x-comment&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
     this.setup = function() {&lt;br /&gt;
       // &amp;quot;this&amp;quot; points the newly created element instance.&lt;br /&gt;
       this.shadow = new ShadowRoot(this); &lt;br /&gt;
       ...;&lt;br /&gt;
     };&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;/element&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no &amp;lt;tt&amp;gt;setup&amp;lt;/tt&amp;gt; callback is given by the author, agent invokes the default behavior.&lt;br /&gt;
It is something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function defaultSetup() {&lt;br /&gt;
  if (this.setup instanceof Function)&lt;br /&gt;
    this.setup();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== HTMLRegistrationElement interface ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Callback=AcceptConstructor]&lt;br /&gt;
interface HTMLRegistrationCreateCallback {&lt;br /&gt;
 HTMLElement create();&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Callback]&lt;br /&gt;
interface HTMLRegistrationSetupCallback {&lt;br /&gt;
 void setup(HTMLElement);&lt;br /&gt;
}:&lt;br /&gt;
&lt;br /&gt;
[Constructor]&lt;br /&gt;
interface HTMLRegistrationElement {&lt;br /&gt;
  attribute String name;&lt;br /&gt;
  attribute HTMLRegistrationCreateCallback create;&lt;br /&gt;
  attribute HTMLRegistrationSetupCallback setup;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Morrita</name></author>
	</entry>
</feed>