Skip to content

Commit

Permalink
Fix customized built-in element is handling and reactions
Browse files Browse the repository at this point in the history
This uses the new "is value" concept introduced to DOM in
whatwg/dom#262, which more correctly implements
the intention that changing the is attribute after element creation does
not impact the processing model, and thus fixes #1298. This allows us to
then fix #1360: custom element callback reactions for customized
built-in elements were not correctly looking up their definition.
  • Loading branch information
domenic committed Jun 1, 2016
1 parent 806bc62 commit d798302
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3165,6 +3165,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li>The <dfn data-noexport="" data-x="create an element" data-x-href="https://dom.spec.whatwg.org/#concept-create-element">create an element</dfn> algorithm</li>
<li>The <dfn data-noexport="" data-x="element interface" data-x-href="https://dom.spec.whatwg.org/#concept-element-interface">element interface</dfn> concept</li>
<li>The concepts of <dfn data-noexport="" data-x-href="https://dom.spec.whatwg.org/#concept-element-custom-element-state">custom element state</dfn>, and of <dfn data-noexport="" data-x="concept-element-defined" data-x-href="https://dom.spec.whatwg.org/#concept-element-defined">defined</dfn> and <dfn data-noexport="" data-x="concept-element-custom" data-x-href="https://dom.spec.whatwg.org/#concept-element-custom">custom</dfn> elements</li>
<li>An element's <dfn data-x="concept-element-is-value" data-x-href="https://dom.spec.whatwg.org/#concept-element-is-value"><code data-x="">is</code> value</dfn></li>

<li><dfn data-noexport="" data-x-href="https://dom.spec.whatwg.org/#mutationobserver"><code>MutationObserver</code></dfn> interface and <dfn data-noexport="" data-x-href="https://dom.spec.whatwg.org/#mutation-observers">mutation observers</dfn> in general</li>

Expand Down Expand Up @@ -65938,7 +65939,8 @@ console.log(plasticButton2.getAttribute("is")); // will output "plastic-button"<

<p>After a <span>custom element</span> is <span data-x="create an element">created</span>,
changing the value of the <code data-x="attr-is">is</code> attribute does not
change the element's behaviour.</p>
change the element's behaviour, as it is saved on the element as its <span
data-x="concept-element-is-value"><code data-x="">is</code> value</span>.</p>

<p><span data-x="autonomous custom element">Autonomous custom elements</span> have the following
element definition:</p>
Expand Down Expand Up @@ -66294,8 +66296,8 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
descendant">shadow-including descendants</span> of <var>document</var>, whose namespace
is the <span>HTML namespace</span> and whose local name is <var>localName</var>, in
<span>shadow-including tree order</span>. Additionally, if <var>extends</var> is non-null, only
include elements that have an attribute named <code data-x="attr-is">is</code> whose value is
<var>name</var>.</p></li>
include elements whose <span data-x="concept-element-is-value"><code data-x="">is</code>
value</span> is equal to <var>name</var>.</p></li>

<li><p>For each element <var>element</var> in <var>upgrade candidates</var>, <span>enqueue a
custom element upgrade reaction</span> given <var>element</var> and
Expand Down Expand Up @@ -66447,15 +66449,11 @@ fetch(articleURL)
input an element <var>element</var>, run the following steps:</p>

<ol>
<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.</p></li>

<li><p>Let <var>is</var> be the value of the attribute in <var>element</var>'s <span>attribute
list</span> whose qualified name is "<code data-x="attr-is">is</code>", if any such attribute
exists, or null otherwise.</p></li>

<li><p>Let <var>definition</var> be the result of <span data-x="look up a custom element
definition">looking up a custom element definition</span> given <var>document</var>,
<var>element</var>'s namespace, <var>element</var>'s local name, and <var>is</var>.</p></li>
definition">looking up a custom element definition</span> given <var>element</var>'s <span>node
document</span>, <var>element</var>'s namespace, <var>element</var>'s local name, and
<var>element</var>'s <span data-x="concept-element-is-value"><code data-x="">is</code>
value</span>.</p></li>

<li><p>If <var>definition</var> is not null, then <span>enqueue a custom element upgrade
reaction</span> given <var>element</var> and <var>definition</var>.</p></li>
Expand Down Expand Up @@ -66510,8 +66508,9 @@ fetch(articleURL)
reactions stack</dfn>, which is initially empty. Each item in the stack is an <dfn>element
queue</dfn>, which is initially empty as well; the <span>element queue</span> at the top of the
stack is called the <dfn>current element queue</dfn>. Each item in an <span>element queue</span>
is an element. (The elements are not necessarily <span>custom</span> yet, since this queue is used
for <span data-x="custom-element-upgrades">upgrades</span> as well.)</p>
is an element. (The elements are not necessarily <span
data-x="concept-element-custom">custom</span> yet, since this queue is used for <span
data-x="custom-element-upgrades">upgrades</span> as well.)</p>

<p>All elements have an associated <dfn>custom element reaction queue</dfn>, initially empty. Each
item in the <span>custom element reaction queue</span> is of one of two types:</p>
Expand All @@ -66536,19 +66535,14 @@ fetch(articleURL)
<ol>
<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.</p></li>

<li><p>If <var>document</var> does not have a <span data-x="concept-document-bc">browsing
context</span>, then abort these steps.</p></li>

<li><p>Let <var>registry</var> be <var>document</var>'s <span
data-x="concept-document-window">associated <code>Window</code></span>'s
<code>CustomElementsRegistry</code> object.</p></li>

<li>
<p>Let <var>definition</var> be the entry in <var>registry</var> with <span
data-x="concept-custom-element-definition-name">name</span> equal to <var>element</var>'s local
name.</p>
<p>Let <var>definition</var> be the result of <span data-x="look up a custom element
definition">looking up a custom element definition</span> given <var>document</var>,
<var>element</var>'s namespace, <var>element</var>'s local name, and <var>element</var>'s <span
data-x="concept-element-is-value"><code data-x="">is</code> value</span>.</p>

<p class="note">This algorithm can only be called when such a definition exists.</p>
<p class="note"><var>definition</var> will never be null; this algorithm will only be called
when such a definition exists.</p>
</li>

<li><p>Let <var>callback</var> be the value of the entry in <var>definition</var>'s <span
Expand Down

0 comments on commit d798302

Please sign in to comment.