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

The CSS Working Group just discussed `Identity of Element.pseudo() return value`.

<details><summary>The full IRC log of that discussion</summary>
&lt;heycam> Topic: Identity of Element.pseudo() return value<br>
&lt;heycam> github: https://github.com/w3c/csswg-drafts/issues/3607<br>
&lt;fantasai> ScribeNicK: fantasai<br>
&lt;fantasai> heycam: The issue here is that the spec doesn't say anything currently about when we need to return the same object that we used before on this function<br>
&lt;fantasai> heycam: The other confusing par tis, the function is defined ot return null if the pseudo doesn't currently exisst<br>
&lt;fantasai> heycam: Already we have a case where sometimes it'll return different values<br>
&lt;fantasai> heycam: But what is meant to happen if e.g. you restyle the element and its ::before content changes to something different<br>
&lt;fantasai> heycam: Do we keep track of whether we went ot null in the interim?<br>
&lt;fantasai> heycam: what is meant to happen?<br>
&lt;fantasai> florian: Would you prefer to return the same object in general to avoid garbage?<br>
&lt;fantasai> florian: or return different objects<br>
&lt;fantasai> heycam: given you want to use these as event targets, I thin it would be best to return the same object<br>
&lt;fantasai> heycam: Otherwise you grabe an object, attach an element, then pull it again to remove your event handler, and it's not there so you can't remove it<br>
&lt;fantasai> florian: You could maybe have an object that is a shallow copy?<br>
&lt;fantasai> florian: Then you'd have the same items on it<br>
&lt;fantasai> florian: that you could reach, although the object identity would be different<br>
&lt;fantasai> heycam: I think that'd be weird<br>
&lt;fantasai> Rossen: How is that different from having a reference to an element<br>
&lt;fantasai> Rossen: and referencing... asynchronously<br>
&lt;fantasai> Rossen: In terms of lifetime and identity, original reference will be held<br>
&lt;fantasai> Rossen: You'll have an element disconnected from the tree<br>
&lt;fantasai> Rossen: You will have some sort of state of whatever it is, and you may use it if it's useful to you<br>
&lt;fantasai> Rossen: but you have understanding that this element is no longer part of DOM<br>
&lt;fantasai> heycam: One difference is that it's a lot less obvious when the underlying thing goes away<br>
&lt;fantasai> heycam: It's determined just by the style values of the element, e.g. what 'content' property value is<br>
&lt;fantasai> heycam: whereas normal elements, it's more obvious when the thing has gone away<br>
&lt;fantasai> Rossen: To me what you're describing is the same as saying, if I have the pseudo element and I ask the containing element<br>
&lt;fantasai> Rossen: If I change the pseudo element to the extent that I need to generate a new pseudo elemen<br>
&lt;fantasai> Rossen: then I expect that everything gets disconnected<br>
&lt;fantasai> Rossen: This would be the same pattern as disconnecting a node from the DOM and still having a reference to it<br>
&lt;fantasai> heycam: I didn't considere that .parent would become null in that sense<br>
&lt;fantasai> heycam: could change the spec<br>
&lt;fantasai> Rossen: It's one thing to change state<br>
&lt;fantasai> Rossen: Different thing to completely change the element<br>
&lt;fantasai> Rossen: which in DOM case, this is removing the element and creating a new one<br>
&lt;fantasai> Rossen: for example, changing a div with a text node<br>
&lt;fantasai> Rossen: That would be equivalent transformation<br>
&lt;fantasai> Rossen: in either case if you get disconnected you still have a reference to the original source element<br>
&lt;fantasai> Rossen: or in this case pseudoelement<br>
&lt;fantasai> Rossen: But it's no longer useful to you, and is discoverable that it's no longer useful to you<br>
&lt;fantasai> florian: To concerns<br>
&lt;fantasai> florian: One, elements that are disconnected from the tree is a thing that exists already<br>
&lt;fantasai> florian: Pseudo-elements isn't<br>
&lt;fantasai> florian: Wondering how many odd entities or situations we'll create by making that exist<br>
&lt;fantasai> florian: Also, for ::before / ::after, that sort-of makes sense<br>
&lt;fantasai> florian: But with e.g. ::selection, the lifecycle is less clear<br>
&lt;fantasai> florian: If you select different things, have you collapsed the range or ... does it change when you change your selection???<br>
&lt;fantasai> florian: having an object that you always return regardless of styling<br>
&lt;fantasai> florian: is not so consistent with the element view of the world you were talking about<br>
&lt;fantasai> florian: But exposes a lot less details that are hard to understand for the author<br>
&lt;fantasai> Rossen: I don't have a ready answer, but I still think that mixing identies and lifetimes is going to be ..<br>
&lt;fantasai> Rossen: Keeping identity but changing type would be horrible<br>
&lt;fantasai> Rossen: Also, we're over time.<br>
&lt;fantasai> Rossen: I don't think we can resolve on this atm<br>
&lt;fantasai> heycam: I think it'd be good for more people to put opinions in the issues<br>
&lt;fantasai> heycam: I think in your model, we'd need to know what causes the identity of the object to chnage.<br>
&lt;fantasai> Rossen: Ok, let's end the call here. Thanks for calling in. We'll chat again next week<br>
&lt;fantasai> Meeting closed.<br>
&lt;heycam> github: end topic<br>
&lt;Rossen> trackbot, end meeting<br>
</details>


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

Received on Thursday, 7 February 2019 01:05:07 UTC