Re: [whatwg/dom] Call "Update attributes from data" whenever PI data is directly set (PR #1511)

foolip left a comment (whatwg/dom#1511)

> Should we have some kind of abstraction for setting a CharacterData node's data? Otherwise we're just going to forget this in the future, no?

I agree this many call sites to "update attributes from data given clone" is not ideal and I've tried some different ways of reducing them. I didn't really like having a "set data" or "update data" helper for CharacterData nodes, because you still have to remember to use that instead of just setting data in all the right places. IMHO it's not a good tradeoff to always use that setter for any CharacterData node, as in the constructors/creators for Comment/CDATASection/Text it's definitely not a ProcessingInstruction.

Another reason that it didn't end up looking nice IMO is that either a helper needs a _piAttributesAlreadyUpdated_ argument, or "replace data" still needs to keep the conditional "update attributes from data" call.

However, I did something else to reduce the number of call sites, by extracting a helper in 7c2a0b818de1c0b332c3b5688ebbac67d980e735. Then we have only two new callers to "update attributes from data given clone", one in a "clone a single node" and one in the new helper.

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

Message ID: <whatwg/dom/pull/1511/c6766849200@github.com>

Received on Tuesday, 10 November 2026 12:06:19 UTC