Re: [whatwg/dom] Define processing instruction attributes (PR #1454)

@annevk commented on this pull request.



>  };</pre>
 
+<dl class=domintro>
+ <dt><code><var ignore>pi</var> = new <a constructor lt="ProcessingInstruction()">ProcessingInstruction(<var>target</var> [, <var>data</var> = ""])</a></code>
+ <dd>Returns a new {{ProcessingInstruction}} <a for=/>node</a> whose
+ <a for=ProcessingInstruction>target</a> is <var>target</var> and
+ <a for=CharacterData>data</a> is <var>data</var>.
+</dl>

This should be made complete.

> @@ -8518,17 +8527,222 @@ interface CDATASection : Text {
 <pre class=idl>
 [Exposed=Window]
 interface ProcessingInstruction : CharacterData {
+  constructor(DOMString target, optional DOMString data = "");

I initially thought this would be a bit ugly compared to using IDL records or some such so you can set the attributes directly, but I think overall it's probably okay if we have to keep around the dual-data-structure anyway.

> +</div>
+
+<div algorithm>
+<p>To <dfn>update attributes from data</dfn> for a {{ProcessingInstruction}} <a for=/>node</a> <var>pi</var>:
+
+<ol>
+ <li><p><a for=map>Clear</a> <var>pi</var>'s <a for=ProcessingInstruction>attribute map</a>.
+
+ <li><p>Let <var>context</var> be the result of <a>creating an element</a> given
+ <var>pi</var>'s <a>node document</a>, "<code>html</code>", and the <a>HTML namespace</a>.
+
+ <li><p>Let <var>markup</var> be the concatentation of "<code>&lt;attrs </code>",
+ <var>pi</var>'s <a for=CharacterData>data</a>, and
+ "<code>&gt;&lt;/attrs&gt;</code>".
+
+ <li><p>Let <var>fragment</var> be the result of invoking the <a>fragment parsing algorithm steps</a> with <var>context</var> and <var>markup</var>.

This looks like it exceeds a 100 columns.

> +  </ol>
+</ol>
+</div>
+
+<div algorithm>
+<p>To <dfn>update data from attributes</dfn> for a {{ProcessingInstruction}} <a for=/>node</a> <var>pi</var>:
+
+<ol>
+ <li><p>Let <var>data</var> be the empty string.
+
+ <li>
+  <p><a for=map>For each</a> <var>name</var> → <var>value</var> of <var>pi</var>'s
+  <a for=ProcessingInstruction>attribute map</a>:
+
+  <ol>
+   <li><p>If <var>data</var> is not the empty string, append U+0020 SPACE to <var>data</var>.

then append*

> +
+<div algorithm>
+<p>The <dfn method for=ProcessingInstruction><code>hasAttribute(<var>name</var>)</code></dfn>
+method steps are:
+
+<ol>
+ <li><p>If <a>this</a>'s <a for=Node>node document</a> is an <a>HTML document</a>, then set
+ <var>name</var> to <var>name</var> in <a>ASCII lowercase</a>.
+
+ <li><p>Return true if <a>this</a>'s <a for=ProcessingInstruction>attribute map</a>[<var>name</var>]
+ <a for=set>exists</a>; otherwise false.
+</ol>
+</div>
+
+<div algorithm>
+<p>To <dfn>update attributes from data</dfn> for a {{ProcessingInstruction}} <a for=/>node</a> <var>pi</var>:

Are we sure this parser is compatible with how xsl-stylesheet is parsed today?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1454#pullrequestreview-3894243554
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1454/review/3894243554@github.com>

Received on Thursday, 5 March 2026 06:54:33 UTC