[Custom]: Remove shadow tree construction from custom elements.
authorDimitri Glazkov <dglazkov@chromium.org>
Wed, 20 Feb 2013 14:53:48 -0800
changeset 714505225bb4a7b
parent 713 5557e62abb77
child 715 677f1e25707d
[Custom]: Remove shadow tree construction from custom elements.
spec/custom/index.html
     1.1 --- a/spec/custom/index.html	Wed Feb 20 11:33:33 2013 -0800
     1.2 +++ b/spec/custom/index.html	Wed Feb 20 14:53:48 2013 -0800
     1.3 @@ -133,7 +133,7 @@
     1.4  The list of names above is the summary of all hyphen-containing names from the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#other-applicable-specifications">applicable specifications</a>, namely the <a href="http://www.w3.org/TR/SVG/eltindex.html">SVG</a> and the <a href="http://www.w3.org/TR/MathML/">MathML</a>.
     1.5  </div>
     1.6  
     1.7 -<p>The <dfn id="dfn-element-definition">element definition</dfn> is an association of a <a href="#dfn-custom-element-name">custom element name</a> and a <a href="http://dom.spec.whatwg.org/#concept-element-namespace">namespace</a> with a <a href="#dfn-custom-element-prototype">custom element prototype</a>, and optionally, a <a href="#dfn-custom-element-template">custom element template</a> and <a href="#dfn-lifecycle-callbacks">lifecycle callbacks</a>.</p>
     1.8 +<p>The <dfn id="dfn-element-definition">element definition</dfn> is an association of a <a href="#dfn-custom-element-name">custom element name</a> and a <a href="http://dom.spec.whatwg.org/#concept-element-namespace">namespace</a> with a <a href="#dfn-custom-element-prototype">custom element prototype</a>, and optionally, <a href="#dfn-lifecycle-callbacks">lifecycle callbacks</a>.</p>
     1.9  
    1.10  <p><dfn id="dfn-element-registration">Element registration</dfn> is a process of associating an <a href="#dfn-element-definition">element definition</a> with a <a href="http://dom.spec.whatwg.org/#concept-document">document</a>. An <a href="#dfn-element-definition">element definition</a> can only be <a href="#dfn-element-registration">registered</a> with one <a href="http://dom.spec.whatwg.org/#concept-document">document</a>. Once <a href="#dfn-element-registration">registered</a>, the <a href="#dfn-custom-element">custom element</a>'s <a href="http://www.w3.org/TR/WebIDL/#dfn-interface">interface</a> <strong>must</strong> be the <a href="http://dom.spec.whatwg.org/#concept-element-interface">element interface</a> for <a href="http://dom.spec.whatwg.org/#concept-attribute-name">name</a> and <a href="http://dom.spec.whatwg.org/#concept-attribute-namespace">namespace</a> values of <a href="#dfn-custom-element-name">custom element name</a> and the <a href="http://dom.spec.whatwg.org/#concept-attribute-namespace">namespace</a> in <a href="#dfn-element-definition">custom element definition</a>, respectively.</p>
    1.11  
    1.12 @@ -151,31 +151,6 @@
    1.13  
    1.14  <p>If both types of <a href="#dfn-custom-element-name">custom element names</a> are provided at the time of element's instantiation, the <a href="#dfn-custom-tags">custom tag</a> <strong>must</strong> win over the <a href="#dfn-type-extension">type extension</a>.
    1.15  
    1.16 -<p>While being instantiated, <a href="#dfn-custom-element">custom elements</a> are given an opportunity to create a <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-dom-subtree">shadow DOM subtree</a> which it <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-host">hosts</a>. The <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-dom-subtree">shadow DOM subtree</a> is populated by cloning an <a href="http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template">HTML template</a>, which is called the <dfn id="dfn-custom-element-template">custom element template</dfn>.
    1.17 -
    1.18 -<p>Creating a <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-dom-subtree">shadow tree</a> <strong>must</strong> follow the <dfn id="dfn-shadow-tree-instantiation">shadow tree instantiation algorithm</dfn>, which <strong>must</strong> be <a href="#dfn-processing-equivalence">equivalent</a> to running these steps:</p>
    1.19 -<div class="algorithm">
    1.20 -<dl>
    1.21 -<dt>Input</dt>
    1.22 -    <dd><var>ELEMENT</var>, the <a href="#dfn-custom-element">custom element</a></dd>
    1.23 -</dl>
    1.24 -<ol>
    1.25 -    <li>Let <var>CHAIN</var> be <var>ELEMENT</var>'s <a href="http://ecma-international.org/ecma-262/5.1/#sec-4.2.1">prototype chain</a>, in reverse order (starting from the end farthest from <var>ELEMENT</var>)</li>
    1.26 -    <li><dfn id="algo-chain-iteration">For each</dfn> item in <var>CHAIN</var>:
    1.27 -    <ol>
    1.28 -        <li>Let <var>ITEM</var> be this item</li>
    1.29 -        <li>Let <var>DEFINITION</var> be a <a href="#dfn-element-registration">registered</a> <a href="#dfn-element-definition">element definition</a> that has <var>ITEM</var> as <a href="#dfn-custom-element-prototype">custom-element prototype</a>.</li>
    1.30 -        <li>If <var>DEFINITION</var> was not found, <strong>stop.</strong></li>
    1.31 -        <li>If <var>DEFINITION</var> has <a href="#dfn-custom-element-template">element template</a>:
    1.32 -        <ol>
    1.33 -            <li>Let <var>TEMPLATE</var> be this template</li>
    1.34 -            <li>Create a <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-root">shadow root</a> with <var>ELEMENT</var> as its <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-host">host</a></li>
    1.35 -            <li><a href="http://www.w3.org/TR/domcore/#dom-node-clonenode">Clone</a> <var>TEMPLATE</var> as contents of this <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-root">shadow root</a></li>
    1.36 -        </ol></li>
    1.37 -    </ol>
    1.38 -</ol>
    1.39 -</div>
    1.40 -
    1.41  <p>All <a href="#dfn-custom-element">custom elements</a> <strong>must</strong> be constructable with a <a href="http://www.w3.org/TR/WebIDL/#dfn-function-object">function object</a>, called <dfn id="dfn-custom-element-constructor">custom element constructor</dfn>. This constructor <strong>must</strong> be created with the <dfn id="dfn-custom-element-constructor-generation">custom element constructor generation algorithm</dfn>, which <strong>must</strong> be <a href="#dfn-processing-equivalence">equivalent</a> to running these steps:</p>
    1.42  <div class="algorithm">
    1.43  <dl>
    1.44 @@ -193,8 +168,7 @@
    1.45          <li>Let <var>NAMESPACE</var> be the <a href="http://dom.spec.whatwg.org/#concept-element-namespace">namespace</a> in <var>DEFINITION</var></li>
    1.46          <li>Let <var>ELEMENT</var> be the <a href="http://dom.spec.whatwg.org/#context-object">context object</a></li>
    1.47          <li>Set <var>ELEMENT</var>'s <a href="http://dom.spec.whatwg.org/#concept-element-local-name">local name</a> to <var>NAME</var>, <a href="http://dom.spec.whatwg.org/#concept-element-namespace">namespace</a> to the <var>NAMESPACE</var>, and <a href="http://dom.spec.whatwg.org/#concept-node-document">node document</a> to the <a href="http://dom.spec.whatwg.org/#concept-document">document</a> with which <var>DEFINITION</var> is registered</li>
    1.48 -        <li>Run the <a href="#dfn-shadow-tree-instantiation">shadow tree instantiation algorithm</a> with <var>ELEMENT</var> as argument</li>
    1.49 -        <li>Run the <a href="#dfn-element-finalization">element finalization algorithm</a> with <var>ELEMENT</var> as argument</li>
    1.50 +        <li>Run the <a href="#dfn-element-initialization">element initialization algorithm</a> with <var>ELEMENT</var> as argument</li>
    1.51          <li>Return <var>ELEMENT</var>.</li>
    1.52      </ol></li>
    1.53  </ol>
    1.54 @@ -208,8 +182,7 @@
    1.55  <p>When an <a href="http://dom.spec.whatwg.org/#concept-element">element</a> is instantiated with the <a href="http://dom.spec.whatwg.org/#dom-document-createelement"><code>createElement</code></a> or <a href="http://dom.spec.whatwg.org/#dom-document-createelementns"><codE>createElementNS</code></a> methods, the method <strong>must</strong> run the following steps <em>after</em> the last step of creating an element and <em>before</em> returning the result:</p>
    1.56  <ol>
    1.57      <li>Let <var>ELEMENT</var> be the newly created <a href="http://dom.spec.whatwg.org/#concept-element">element</a></li>
    1.58 -    <li>Run the <a href="#dfn-shadow-tree-instantiation">shadow tree instantiation algorithm</a> with <var>ELEMENT</var> as argument</li>
    1.59 -    <li>Run the <a href="#dfn-element-finalization">element finalization algorithm</a> with <var>ELEMENT</var> as argument</li>
    1.60 +    <li>Run the <a href="#dfn-element-initialization">element initialization algorithm</a> with <var>ELEMENT</var> as argument</li>
    1.61  </ol>
    1.62  </div>
    1.63  
    1.64 @@ -221,7 +194,7 @@
    1.65  
    1.66  <p><span class="fixme">Specify how custom elements are defined declaratively</span></p>
    1.67  
    1.68 -<p>The <dfn id="dfn-element-finalization">element finalization algorithm</dfn> <strong>must</strong> be <a href="#dfn-processing-equivalence">equivalent</a> to running these steps:</p>
    1.69 +<p>The <dfn id="dfn-element-initialization">element initialization algorithm</dfn> <strong>must</strong> be <a href="#dfn-processing-equivalence">equivalent</a> to running these steps:</p>
    1.70  
    1.71  <div class="algorithm">
    1.72  <dl>
    1.73 @@ -279,7 +252,7 @@
    1.74              <li>Append <var>ATTRIBUTE</var> to <var>UPGRADE</var>'s <a href="http://www.w3.org/TR/domcore/#concept-element-attribute">attribute list</a></li>
    1.75          </ol></li>
    1.76          <li><a href="">Insert</a> <var>UPGRADE</var> into <var>PARENT</var> before <var>REFERENCE</var> with <em>suppress observers flag</em> set</li>
    1.77 -        <li>Invoke <a href="#dfn-element-finalization">element finalization algorithm</a> with <var>UPGRADE</var> and <var>DEFINITION</var> as arguments</li>
    1.78 +        <li>Invoke <a href="#dfn-element-initialization">element initialization algorithm</a> with <var>UPGRADE</var> and <var>DEFINITION</var> as arguments</li>
    1.79         <li>On <var>ELEMENT</var>, <a href="http://www.w3.org/TR/domcore/#concept-event-fire">fire</a> an <a href="#api-element-replace-event"><code>ElementReplaceEvent</code></a> event, initialized with values <em>upgrade</em> as <var>UPGRADE</var> and <em>bubbles</em> as <code>false</code>.</li>
    1.80          <li>On <var>UPGRADE</var>, <a href="http://www.w3.org/TR/domcore/#concept-event-fire">fire an event</a> named <code>elementupgrade</code> with its <code>bubbles</code> attribute set to <code>true</code>.</li>
    1.81      </ol></li>
    1.82 @@ -322,10 +295,9 @@
    1.83  </div>
    1.84  
    1.85  <div class="informative">
    1.86 -<p>This modification to <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#create-an-element-for-the-token">creating an element for a token</a> has the following consequences:</p>
    1.87 +<p>This modification to <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#create-an-element-for-the-token">creating an element for a token</a> has the following consequence:</p>
    1.88  <ul>
    1.89      <li>The <a href="#dfn-custom-element">custom elements</a> are created when <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#parsing">parsing HTML documents</a> or <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-parsing-algorithm">fragments</a></li>
    1.90 -    <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#parsing">Parsing HTML documents</a> or <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-parsing-algorithm">fragments</a> could trigger creation of a <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-root">shadow root</a> and instantiation of a <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-dom-subtree">shadow DOM subtree</a></li>
    1.91  </ul>
    1.92  </div>
    1.93  
    1.94 @@ -371,7 +343,6 @@
    1.95  
    1.96  dictionary <dfn id="api-element-registration-options">ElementRegistrationOptions</dfn> {
    1.97      object? <a href="#var-options-prototype">prototype</a> = null;
    1.98 -    <a href="http://www.w3.org/TR/domcore/#documentfragment">DocumentFragment</a>? <a href="#var-options-template">template</a> = null;
    1.99      <a href="#api-lifecycle-callbacks">LifecycleCallbacks</a>? <a href="#var-options-lifecycle">lifecycle</a> = null;
   1.100  };
   1.101  
   1.102 @@ -390,7 +361,6 @@
   1.103      <dd><var>DOCUMENT</var>, the <a href="http://dom.spec.whatwg.org/#context-object">context object</a> of the method</dd>
   1.104      <dd><var id="var-document-register-name">NAME</var>, the <a href="#dfn-custom-element-name">custom element name</a> of the element being registered</dd>
   1.105      <dd><var id="var-options-prototype">PROTOTYPE</var>, the <a href="#dfn-custom-element-prototype">custom element prototype</a>, optional</dd>
   1.106 -    <dd><var id="var-options-template">FRAGMENT</var>, the <a href="http://www.w3.org/TR/domcore/#documentfragment">document fragment</a> that represents the <a href="#dfn-custom-element-template">custom element template</a>, optional</dd>
   1.107      <dd><var id="var-options-lifecycle">LIFECYCLE</var>, the <a href="#dfn-lifecycle-callbacks">lifecycle callbacks</a>, optional</dd>
   1.108  <dt>Output</dt>
   1.109      <dd><var>CONSTRUCTOR</var>, the <a href="#dfn-custom-element-constructor">custom element constructor</a></dd>
   1.110 @@ -405,10 +375,8 @@
   1.111          <li>If <var>INTERFACE</var> <a href="http://www.w3.org/TR/WebIDL/#dfn-inherit">inherits</a> from <a href="http://www.w3.org/TR/SVG/types.html#InterfaceSVGElement"><code>SVGElement</code></a>, set <var>NAMESPACE</var> to <a href="http://www.w3.org/2000/svg">SVG Namespace</a></li>
   1.112          <li>Otherwise, if <var>INTERFACE</var> does not <a href="http://www.w3.org/TR/WebIDL/#dfn-inherit">inherit</a> from <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement"><code>HTMLElement</code></a>, <a href="http://dom.spec.whatwg.org/#concept-throw">throw</a> a <a href="http://dom.spec.whatwg.org/#namespaceerror"><code>NamespaceError</code></a> and <strong>stop</strong>.</li>
   1.113      </ol></li>
   1.114 -    <li>If <var>FRAGMENT</var> is not <strong>null</strong>, let <var>TEMPLATE</var> be <a href="http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template">HTML template</a> with <var>FRAGMENT</var> as <a href="http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents">template contents</a></li>
   1.115 -    <li>Otherwise, let <var>TEMPLATE</var> be <strong>null</strong></li>
   1.116      <li>If there already exists a <a href="#dfn-element-definition">definition</a> that has both <var>NAME</var> and <var>NAMESPACE</var> and/or has <var>PROTOTYPE</var>, throw a <a href="http://dom.spec.whatwg.org/#notsupportederror"><code>NotSupportedError</code></a> and <strong>stop</strong>.</li>
   1.117 -    <li>Let <var>DEFINITION</var> be the tuple of (<var>NAME</var>, <var>NAMESPACE</var>, <var>PROTOTYPE</var>, <var>TEMPLATE</var>, <var>LIFECYCLE</var>)</li>
   1.118 +    <li>Let <var>DEFINITION</var> be the tuple of (<var>NAME</var>, <var>NAMESPACE</var>, <var>PROTOTYPE</var>, <var>LIFECYCLE</var>)</li>
   1.119      <li><a href="#dfn-element-registration">Register</a> the <var>DEFINITION</var> with <var>DOCUMENT</var></li>
   1.120      <li>For <var>DOCUMENT</var> tree and every <a href="http://www.w3.org/TR/shadow-dom/#dfn-shadow-dom-subtree">shadow DOM subtree</a> <a href="http://www.w3.org/TR/shadow-dom/#dfn-enclosed-subtree">enclosed</a> by <var>DOCUMENT</var> tree:
   1.121      <ol>