Skip to content

Commit

Permalink
Use new "create an element" hook in cloning and parsing
Browse files Browse the repository at this point in the history
Tentatively closes #424.
  • Loading branch information
domenic committed Mar 8, 2016
1 parent 2d13bb2 commit 674b0b2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions spec/custom/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ <h3>Registry-Related Changes to the HTML Standard</h3>
<p>Inside the algorithm for the <a href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-document-open"><code>document.open()</code></a> method, add a step (near step 18, replacing the <a href="https://html.spec.whatwg.org/multipage/dom.html#document"><code>Document</code></a>'s singleton objects) that sets the <a href="https://html.spec.whatwg.org/multipage/dom.html#document"><code>Document</code></a>'s custom element registry to a new empty set.</p>
</section>

<section id="clone-modifications-to-dom">
<h3>Cloning Changes to the DOM Standard</h3>

<p>The <a href="https://dom.spec.whatwg.org/#concept-node-clone">clone a node</a> algorithm will need to be modified as follows. A new case, separate from the main switch, will be needed to generate <var>copy</var> for <code>Element</code>s. It should use <a>create an element</a>, given <var>document</var>, <var>node</var>'s local name, <var>node</var>'s namespace prefix, <var>node</var>'s namespace, and the value of <var>node</var>'s <code>is</code> attribute (if present). The <var>synchronous custom elements flag</var> should be unset.</p>

</section>

</section>

<section id="custom-element-lifecycle">
Expand Down Expand Up @@ -355,8 +362,6 @@ <h3>Enqueuing and Invoking Callbacks</h3>
<li>When transitioning back from the user agent code to script, pop the <a>element queue</a> from the <a>processing stack</a> and <a>invoke custom element actions</a> in that queue.</li>
</ul>

<p>Additionally, any time an element is created in the <a href="https://dom.spec.whatwg.org/#html-namespace">HTML namespace</a>, the user agent must <a>enqueue a custom element upgrade</a>.</p>

<p class="warning">This needs to become more precise. Find all platform APIs that can create elements? Or invent a new algorithm for creating elements and make sure everyone calls it?</p>

<div class="note">As described, these actions wrap every user agent-implemented method or property accessor. The intended effect is that any lifecycle callbacks, enqueued as a result of running these methods or accessors are invoked prior to returning control back to script. If a method or accessor is known to never enqueue a custom element action, the user agent could choose not to wrap it as a performance optimization.</div>
Expand Down Expand Up @@ -694,7 +699,7 @@ <h3>Changes to the HTML Parser</h3>

<p class="warning">This section needs a lot more detail added on how exactly it is going to patch [[HTML]], in order to execute script during parsing.</p>

<p>To enable instantiating <a data-lt="custom element">custom elements</a> during <a href="https://html.spec.whatwg.org/multipage/syntax.html#tree-construction">tree construction</a>, whenever <a href="https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token">creating</a> a <a>custom element</a>, the user agent must pause (similar to when parsing <code>&lt;script&gt;</code>) and run <a href="https://tc39.github.io/ecma262/#sec-construct">Construct</a>(the relevant <a>custom element constructor</a>). It'll need to handle errors and cases where the wrong interface is returned.</p>
<p>To enable instantiating <a data-lt="custom element">custom elements</a> during <a href="https://html.spec.whatwg.org/multipage/syntax.html#tree-construction">tree construction</a>, whenever <a href="https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token">creating</a> a <a>custom element</a>, the user agent must pause (similar to when parsing <code>&lt;script&gt;</code>) and run <a>create an element</a> with the appropriate argument, including with the <var>synchronous custom elements flag</var> set.</p>

<div class="note">
<p>This modification to <a href="https://html.spec.whatwg.org/multipage/syntax.html#tree-construction">tree construction</a> has the consequence of <a data-lt="custom element">custom elements</a> being created when <a href="https://html.spec.whatwg.org/multipage/syntax.html#parsing">parsing HTML documents</a> or <a href="https://html.spec.whatwg.org/multipage/syntax.html#html-fragment-parsing-algorithm">fragments</a>. Probably we need to tweak this a bit so that fragment parsing is done differently (with upgrade semantics).</p>
Expand Down

0 comments on commit 674b0b2

Please sign in to comment.