Re: [whatwg/dom] ProcessingInstruction attribute values containing \r don't roundtrip (Issue #1526)

foolip left a comment (whatwg/dom#1526)

The problem is that the escaping happens when calling `pi.setAttribute('x', 'y\nz')` or something else that trigger changes PI attributes and calls https://dom.spec.whatwg.org/#update-data-from-attributes.

But the `pi.data` setter doesn't do such escaping (that would be hard) and when serializing a PI, it's simply concatenating the data without further escaping.

Using the escaping rules for XML attribute values (adding \r\n\t) would enable XML roundtripping when using the intended API, and we could say that's an improvement and just do that.

If we also wanted to ensure that the attribute map as updated after setting `pi.data` survives roundtripping, then we'd need to normalize `pi.data` at some point, but that has high compat risk for uses of PIs that don't look like XML attributes.

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

Message ID: <whatwg/dom/issues/1526/6823287865@github.com>

Received on Thursday, 12 November 2026 12:13:47 UTC