Re: [csswg-drafts] [css-pseudo-4] Identity of Element.pseudo() return value (#3607)

My main argument for keeping identity stable (and thus caching objects upon first access) is that they're *effectively* DOM nodes (no children or attributes, but they have style, at least), and DOM nodes can be compared by object identity. I suspect it will be useful to be able to ask "is the pseudo in this variable also present in this array?", etc. Without stable object identity, this will be a much more annoying question to answer.

Having a stable identity doesn't prevent them from being collected; the DOM node should only have a weak reference to its pseudos. So if someone iterates the tree and pings every pseudo, it'll result in an explosion of pseudo nodes, but if they're not holding onto them they'll all die in the next collection.

This means they're observably not the same object in the presence of expandos, but I'm okay with that. I just don't want people to be able to ask for a pseudo, store it, then ask again and get a different object that's not === to the first.

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

Received on Monday, 25 February 2019 15:07:25 UTC