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

noamr left a comment (whatwg/dom#1454)

> I've changed this to always use the HTML parser now. The constraints of wanting to support `<?marker name=x>` (without quotes) and not wanting the APIs to depend on context only leaves option 3 and 5 from [#1454 (comment)](https://github.com/whatwg/dom/pull/1454#issuecomment-4034420660), and reusing the HTML parser is the simplest of the two.
> 
> On lowercasing, I think this behavior might still be surprising:
> 
> ```
> pi = new ProcessingInstruction('target', 'FOO=v1');
> pi.getAttribute('foo') == 'v1'; // normal in HTML, no surprise
> pi.setAttribute('FOO', 'v2');
> pi.getAttribute('foo') == 'v1' && pi.getAttribute('FOO') == 'v2'; // unlike HTML, but OK
> pi.data += ' ';
> pi.getAttribute('foo') == 'v2' && !pi.hasAttribute('FOO'); // collapsed after roundtrip, surprise?
> ```
> 
> We could (1) live with it (2) lowercase in all APIs or (3) use a bespoke parser that preserves attribute case. Any of these would be OK for me.
> 
> If we stick with the HMTL parser, there's also a layering question remaining. Both "Parse HTML from a string" and "escaping a string" would need to be exported in HTML for this to work as-is, but I think it would be cleaner to add and export "parse attributes" and "serialize attributes" to HTML for this purpose.

Always lowercasing in the PI attribute API makes sense to me.

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

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

Received on Thursday, 12 March 2026 15:21:28 UTC