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

foolip left a comment (whatwg/dom#1454)

The approach here is to parse attributes from the PI data, and to keep data and attributes in sync whenever one of them changes. Alternatives considered:

**Attribute mode:** Treat `data` as legacy and switch to "attribute mode" whenever attributes are mutated, replacing `data` with the empty string and optionally making it readonly. Serialization would need to change to use the attributes in this mode. Not pursued because `setAttribute()` would have the non-obvious side effect of making future `data` mutations throw or (alternatively) have no effect on serialization. This option is only attractive if it could be the default, but I can't imagine that's web compatible.

**Just `data`:** Parse `data` whenever getting an attribute. This seems close to how Gecko handled attributes for `<?xml-stylesheet?>`. But updating `data` in `setAttribute()` requires a parsing all attributes. There would be no observable difference to the current keep-everything-in-sync approach.

**Attributes for HTML, `data` for XML:** Since PIs are new in HTML, we could have "attribute mode" in HTML and keep `data` behavior intact for XML. But this would make the APIs significantly different in HTML and XML documents, and it would leave `<?xml-stylesheet?>` unexplained.

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

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

Received on Thursday, 5 March 2026 10:11:32 UTC