Skip to content

Commit 4c5586a

Browse files
committed
Use DOM's node creation algorithms in the XML parser
The XML parser only said how to create elements, through create an element for a token, which always uses a null prefix. The other nodes it creates had no specified realm, and its processing instructions no attribute map, so getAttribute() returned null for them. Give create an element for a token an optional prefix and name a creation algorithm for each type of node, as 85f453b did for the HTML parser.
1 parent a5e1501 commit 4c5586a

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

‎source‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,6 +3255,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
32553255

32563256
<ul class="brief">
32573257
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-attr"><code>Attr</code></dfn> interface</li>
3258+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-cdatasection"><code>CDATASection</code></dfn> interface</li>
32583259
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-characterdata"><code>CharacterData</code></dfn> interface</li>
32593260
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-comment"><code>Comment</code></dfn> interface</li>
32603261
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-domimplementation"><code>DOMImplementation</code></dfn> interface</li>
@@ -3424,6 +3425,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
34243425
<li>The <dfn data-x="create an element" data-x-href="https://dom.spec.whatwg.org/#concept-create-element">create an element</dfn> algorithm</li>
34253426
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#create-a-document">create a document</dfn>,
34263427
<dfn data-x-href="https://dom.spec.whatwg.org/#create-a-text-node">create a text node</dfn>,
3428+
<dfn data-x-href="https://dom.spec.whatwg.org/#create-a-cdata-section-node">create a CDATA section node</dfn>,
34273429
<dfn data-x-href="https://dom.spec.whatwg.org/#create-a-doctype">create a doctype</dfn>,
34283430
<dfn data-x-href="https://dom.spec.whatwg.org/#create-a-comment-node">create a comment node</dfn>,
34293431
<dfn data-x-href="https://dom.spec.whatwg.org/#create-a-processing-instruction-node">create a processing instruction node</dfn>, and
@@ -145001,8 +145003,8 @@ dictionary <dfn dictionary>StorageEventInit</dfn> : <span>EventInit</span> {
145001145003

145002145004
<div algorithm>
145003145005
<p>To <dfn data-x="create an element for the token">create an element for a token</dfn>, given a
145004-
token <var>token</var>, a string <var>namespace</var>, and a <code>Node</code> object
145005-
<var>intendedParent</var>:</p>
145006+
token <var>token</var>, a string <var>namespace</var>, a <code>Node</code> object
145007+
<var>intendedParent</var>, and an optional string-or-null <var>prefix</var> (default null):</p>
145006145008

145007145009
<ol>
145008145010
<li><p>If the <span>active speculative HTML parser</span> is not null, then return the result of
@@ -145054,8 +145056,8 @@ dictionary <dfn dictionary>StorageEventInit</dfn> : <span>EventInit</span> {
145054145056

145055145057
<li>
145056145058
<p>Let <var>element</var> be the result of <span data-x="create an element">creating an
145057-
element</span> given <var>document</var>, <var>localName</var>, <var>namespace</var>, null,
145058-
<var>is</var>, <var>willExecuteScript</var>, and <var>registry</var>.</p>
145059+
element</span> given <var>document</var>, <var>localName</var>, <var>namespace</var>,
145060+
<var>prefix</var>, <var>is</var>, <var>willExecuteScript</var>, and <var>registry</var>.</p>
145059145061

145060145062
<p class="note">This will cause <span data-x="custom element constructor">custom element
145061145063
constructors</span> to run, if <var>willExecuteScript</var> is true. However, since we
@@ -150620,11 +150622,26 @@ console.assert(container.firstChild instanceof SuperP);
150620150622

150621150623
<p>This <code>Document</code> must then be populated with DOM nodes that represent the tree
150622150624
structure of the input passed to the parser, as defined by <cite>XML</cite>, <cite>Namespaces
150623-
in XML</cite>, and <cite>DOM</cite>. When creating DOM nodes representing elements,
150624-
the <span data-x="create an element for the token">create an element for a token</span> algorithm
150625-
or some equivalent that operates on appropriate XML data structures must be used, to ensure the
150626-
proper <span data-x="element interface">element interfaces</span> are created and that <span
150627-
data-x="custom element">custom elements</span> are set up correctly.</p>
150625+
in XML</cite>, and <cite>DOM</cite>. These nodes must be created using the following
150626+
algorithms:</p>
150627+
150628+
<ul>
150629+
<li><p>For elements, <span data-x="create an element for the token">create an element for a
150630+
token</span>, given the element's prefix, to ensure the proper <span data-x="element
150631+
interface">element interfaces</span> are created and that <span data-x="custom element">custom
150632+
elements</span> are set up correctly.</p></li>
150633+
150634+
<li><p>For <code>Text</code> nodes, <span>create a text node</span>.</p></li>
150635+
150636+
<li><p>For <code>CDATASection</code> nodes, <span>create a CDATA section node</span>.</p></li>
150637+
150638+
<li><p>For <code>Comment</code> nodes, <span>create a comment node</span>.</p></li>
150639+
150640+
<li><p>For <code>ProcessingInstruction</code> nodes, <span>create a processing instruction
150641+
node</span>.</p></li>
150642+
150643+
<li><p>For <code>DocumentType</code> nodes, <span>create a doctype</span>.</p></li>
150644+
</ul>
150628150645

150629150646
<p>For the operations that the <span>XML parser</span> performs on the <code>Document</code>'s
150630150647
tree, the user agent must act as if elements and attributes were individually appended and set

0 commit comments

Comments
 (0)