Re: [csswg-drafts] [css-pseudo-4] Should Element.pseudo("unknown") be an error or return null? (#3603)

The CSS Working Group just discussed `Should Element.pseudo("unknown") be an error or return null?`.

<details><summary>The full IRC log of that discussion</summary>
&lt;dael> Topic: Should Element.pseudo("unknown") be an error or return null?<br>
&lt;dael> github: https://github.com/w3c/csswg-drafts/issues/3603<br>
&lt;dael> fantasai: Somewhat related to #3607about identity of the pseudo<br>
&lt;dael> leaverou: Does it present null in any other case? If it's not defined at all does it return null?<br>
&lt;dael> fantasai: That's an open question<br>
&lt;dael> leaverou: In general errors meandev have to handle. But we needto be able to distinguish doesn't exist and not defined. Feature detection needs to be possible<br>
&lt;fantasai> Questions:<br>
&lt;dael> fantasai: Open questions are should element.pseudo always return same object even if you removet he style that generated it? Other is if it doesn't exist in box tree do we get an object back? When we request something that doesn't exist b/c not supported what do we return?<br>
&lt;dael> TabAtkins: Addressed first question last week. Keeping objected identity stable is useful. Question of what to we return when before doesn't have a property and can you fiddle with an object. Second question, we do need to distinguish between a pseudo that doesn't exist and one that isn't valid. I don't think it's useful to return null if a pseduo element doesn't exist on an element. Perhaps a bool to say if it exists or not<br>
&lt;dael> TabAtkins: The for the unknown thing where you put ::foo it should throw an error. Even thought CSS style sheets can be forgiving, JS APIs shoudl throw in clear error cases.<br>
&lt;florian> q+<br>
&lt;dael> fremy: I think it makes sense to return an object all the time. On the error part I'm less sure b/c we'll have compat issues and errors can cause entire thing not to work. Less sure but understand arguement<br>
&lt;dael> leaverou: It's impossible in JS to tell if it's that the element doesn't exist or something else went wrong. You can sort of guess but not be sure<br>
&lt;dael> TabAtkins: We can return different types of errors. We don't throw that many errors and you can tell from type. Message will usually let you know what's going on<br>
&lt;dael> leaverou: From console, but can't programatically detect<br>
&lt;dael> TabAtkins: But there'sone error it can cause<br>
&lt;dael> leaverou: What about the future<br>
&lt;dael> florian: With this if you start nesting and I don't know if that's same error as asking for a pseudo that doesn't exist<br>
&lt;florian> q-<br>
&lt;dael> TabAtkins: Can't ask for a pseudo on a pseudo<br>
&lt;dael> fantasai: I think if we're deciding element returns null when it doesn't exist it makes sense, but if we're not we should return an error<br>
&lt;dael> astearns: Sounded like 3 parts to TabAtkins summary. 1) always return<br>
&lt;dael> TabAtkins: the same object for a give element/pseudo element pair<br>
&lt;TabAtkins> 1. Always return the same object for a given (element, pseudo-element) pair.<br>
&lt;dael> astearns: Always return same object. Return an object for when a element exists<br>
&lt;leaverou> Btw a historical case that may help: In old IE, element.style[foo] would error if the value was invalid. This was very widely considered as annoying by developers, until eventually IE changed and stopped throwing.<br>
&lt;dael> fremy: That means you need ot keep object for lifetime of element. You could have to store a gazillion objects which you don't need. I would have to check<br>
&lt;dael> florian: Garbage detected?<br>
&lt;dbaron> s/detected/collected/<br>
&lt;dael> s/fremy/emilio<br>
&lt;leaverou> s/element.style[foo]/setting element.style.foo/<br>
&lt;dael> emilio: I guess it's not observable. Any other that does the same?<br>
&lt;dbaron> (discussion about the element keeping a weak reference)<br>
&lt;dael> fremy: [missed] if you drop the reference it's garbage collected and you get the new one<br>
&lt;dael> fremy: Not possible to notice because you don't have anywhere to join<br>
&lt;fremy> s/join/compare to/<br>
&lt;dael> TabAtkins: If you ask for a ready promise those are cached and you're not calling because ready state has not changed. That sort of retention of objects is not uncommon<br>
&lt;dael> emilio: font face it's one object and this could be many objects. If it's a problem we can face it<br>
&lt;dael> TabAtkins: If you're iterating the entire tree, that's weird<br>
&lt;dael> emilio: I've seen people do it<br>
&lt;dael> florian: Pseudo with a certain style, you look at all<br>
&lt;dael> fantasai: One thing we could do is return null if doesn't exist on element. If at any point it does exist browser has to maintain the reference. Function might return null or that object, but never another. SO if pseudo element at some point exists you keep that reference.<br>
&lt;dael> TabAtkins: psueod element does exist- if there isn't css setting the before would we return null when asking for the before pseudo<br>
&lt;dael> emilio: Also what happens when display on sub tree? I don't know<br>
&lt;fremy> +1 to what TabAtkins just said<br>
&lt;dael> TabAtkins: I'm unhappy with it because it means you can't use this API to toggle a pseudo element on. You have to go through normal css which is a more complicated redirection. Sounds good but messes up too much<br>
&lt;dael> plinss[m]: Isn't that a feature? SHould we be able to create pseudo not backed by css?<br>
&lt;dael> fantasai: Currently has a .style that allows you to set and have it exist.<br>
&lt;Rossen> q+<br>
&lt;dael> fantasai: Interesting thing is to plinss[m] point you can't serialize that back out. WE have style that will serialize out for .style, but not for a pseudo element.<br>
&lt;dael> TabAtkins: If we accept nesting proposal style auto upgrades to be able to support that. Have to define, but you can embed a nested style in the style attribute. There's a route to make it serializable<br>
&lt;astearns> ack Rossen<br>
&lt;emilio> Rossen++<br>
&lt;dbaron> Another maybe-silly option is a null/undefined distinction, if you want to think of .pseudo() as sort of like a shorthand for a long list of DOM properties (where undefined means "not implemented" or "the browser doesn't know about it" and null means "known but not present")<br>
&lt;dael> Rossen: Question- Is anyone working with any DOM or HTML folks on this? Curious to their PoV. Sounds like a pretty overarching API that we should be working with at least DOM folks. I'd hate to see something like this worked on for so long and then go back to square one.<br>
&lt;dael> Rossen: Perhaps with an envoy it would be good to get their PoV<br>
&lt;dael> emilio: We can ask for feedback<br>
&lt;TabAtkins> dbaron, I don't see a good reason to return undefined vs throwing, tho.<br>
&lt;dael> fantasai: Would like to try and resolve and we can reopen if they give feedback and get a publication out to request a review<br>
&lt;AmeliaBR> If we accept Tab's "route to serialization" by allowing pseudo-element styles in the inline style of the main element, doesn't that also open up a "route to dynamically generating a pseudo-element" by declaring a `style="::before{content:"text"}` on the parent element's style object?<br>
&lt;dael> astearns: Would be nice, but not sure I'm hearing consensus<br>
&lt;dael> astearns: I agree figuring this stuff out does make this issue about a non-existent pseudo...how we answer all these questions does make a difference on how we address this particular issue<br>
&lt;fantasai> AmeliaBR, only if you escape those quotes properly :)<br>
&lt;TabAtkins> `style="&amp;::before{content:'text'}"`, but yes<br>
&lt;dael> Rossen: I'm hearing a lot more questions then suggested answers. Doesn't suggest you're ready to resolve. If we're looking to push an updated version of spec I don't thinkw e need to rush a decision<br>
&lt;dael> astearns: Issue on the agenda is just unknown pseudo elements. Are there other issues for psuedos that can hop on and off of existance?<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/3607<br>
&lt;dael> fantasai: #3607<br>
&lt;dael> astearns: Gotcha<br>
&lt;fantasai> That transcript misses some of Tab's follow-up comments<br>
&lt;dael> astearns: Not happy to not resolve, but I don't think we have a plan. What about we come up with a proposal for both issues, discuss at F2F, come to a decision there. We use time up to F2F to reach out to DOM people and anyone else that would have real input on what to decide<br>
</details>


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

Received on Wednesday, 13 February 2019 17:39:02 UTC