Re: [csswg-drafts] Proposal for custom matched sets of elements (#7679)

> The "performance issues" with changing the DOM are related to invalidating styles for affected elements, which would be exactly the same with this, yeah? (And, unless this is internally implemented using the same descendant-caching optimizations that classes currently use, the invalidation cost will be worse than just modifying classes.)

Performance issues I had in mind were more user land. Frameworks and libraries tends to "watch" the DOM for state changes. Performance is a secondary concern.

> Is there another issue with modifying classes that I'm missing?

The main issue is that sometimes DOM manipulation is unexpected or unintuitive.
For example in the polyfill for `:has()` we add attributes on matching elements.

Consumers of the polyfill do not expect this behaviour.
They expect the polyfill to leave the DOM as-is.

Examples of how these DOM manipulations look :

<img width="334" alt="Screenshot 2022-09-08 at 00 39 21" src="https://user-images.githubusercontent.com/11521496/188995816-cd441d88-8dbd-4348-b652-5cb0a8ee3842.png">

_warning: this clip contains flashing content_

https://user-images.githubusercontent.com/11521496/188995666-4e29682e-098a-4b60-b559-9fbcf7a378a2.mp4



-- 
GitHub Notification of comment by romainmenke
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7679#issuecomment-1239985407 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 7 September 2022 22:50:09 UTC