-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fieldset and details have inconsistent definitions in the spec #3805
Comments
I'm pretty sure this was written this way because at least Apple and Google have voiced interest in implementing these new elements through "internal" shadow tree mechanisms. If instead we described them in terms of CSS boxes (or whatever the latest terminology is there) that would no longer be feasible. (To me it seems somewhat acceptable to keep |
The problem is that the resulting rendering is kinda broken, from my point of view. Maybe that means that the shadow DOM spec needs changes of some sort, but what we basically have here is prioritizing implementors' interests over authors' interests, from my point of view. |
cc @whatwg/components |
@bzbarsky do I understand correctly that this issue is really about |
A quick test with :before shows different rendering between WebKit/Blink, Gecko, and Edge. http://software.hixie.ch/utilities/js/live-dom-viewer/saved/6088 |
Questions I see being raised here:
|
To summarize: Browser implementations of Which is pretty much what I would expect, since these pseudos are attached to the parent I certainly wouldn't want to not be able to use generated content on a closed So, the confusion seems to be that the I've always seen the rendering of For me, the only confusing part of the whole system is the tree-rearrangement created when a PS, If it's helpful to anyone else, a pen comparing details vs fieldset: https://codepen.io/AmeliaBR/pen/wEQPMN |
@AmeliaBR thank you for writing that down. I think I see the difference between (Note that I filed w3c/csswg-drafts#3126 on question 3 above, which also seems to indicate that the way things are today is okay.) |
I'm embarrassed to realize I commented without doing cross-browser testing. Indeed, Gecko (Firefox 63 tested) does display the summary before the MS Edge doesn't implement details/summary at all (as of the current stable version, EdgeHTML 17), so they just lay them out as unknown container elements. However, they also handle fieldset/legend different than the other browser rendering engines. Instead of pulling the But, since all the other major browser engines agree on fieldset/legend, maybe that one can just be called a bug on MS Edge. Although to be fair, my example is technically invalid markup, since the spec says that legend must be the first child. |
Can we just make |
By that argument the resulting rendering of
is also weird, no? Whereas it makes perfect sense if you think of it in terms of shadow trees. @rniwa @mstensho @hayatoito any thoughts on changing this in Chromium/WebKit? |
I don't see anything weird about that example. Anyway, this issue isn't about if
doesn't give the same results as your example. That's inconsistent, surprising and in violation of the quoted css-pseudo spec IMO. |
Hm? They don't go outside the block. The only thing is that pseudo-elements are inserted into the flat tree, not the pre-flattening DOM tree. So they're not scooped up by slots or anything; a ::before is always the first child of its originating element, regardless of what shadowy trickery the element might be doing with the order of its actual DOM children. This is how author-defined shadow hosts work, and should be how UA-defined ones work too. (And the browser shouldn't, if possible to avoid, be specifying behaviors that aren't achieveable by authors. The only way to rationalize (It looks like this particular interaction isn't well-specified at the moment. Happy to fix that, apologies for missing it.) |
Our complaint is that (quoting from the OP): ":before and ::after on a You're completely ignoring our complaint by saying: "well, this is how it works". Sad. |
I agree that it would be useful to allow ::before/::after to be on the "contents" of a |
It wasn't my intention to ignore your complaint; you were saying that the behavior was wrong/inconsistent, and I was answering that it's not. The current behavior is indeed the correct Shadow DOM behavior for ::before/::after. Insofar as you were saying that the current behavior was undesirable, apologies, I thought the CSS repo's thread had already been linked over here and could be assumed as part of the general knowledge. That lack has been corrected by my latest (immediately preceding) comment. Also:
To the best of my knowledge, this is consistent with fieldset/legend too. They have magical rendering that's not author-exposed, equivalent to some sort of |
I respectfully disagree. The built-in Shadow DOM on
Quoting from the css-pseudo spec (my emphasis):
Hence, the pseudos should be hidden when the
That's nice, but it's still a workaround in my opinion. I'd prefer |
BTW, would this hypothetical example work in an UA that implements <details style="-webkit-appearance:fieldset">
<summary style="-webkit-appearance:legend">LEGEND</summary>
CONTENTS
</details> ("work" as in: clicking the LEGEND hides the CONTENTS, but nothing else.) |
FYI, I put together a twitter poll to gather some feedback from web authors about what they expect from pseudo elements on https://twitter.com/AmeliasBrain/status/1046860654659887104 Early results are fairly divided, though, so I'm not sure it's going to result in a clear preference for one way or the other. |
For the record, here are the questions & responses to that poll:
From replies to the tweet, it is clear that many are rather confused about the underlying model & how it is supposed to map to CSS concepts in general. We can't go back in time & create a more logical markup model. But I suspect it would be helpful to create a model that we can clearly define using established standards (e.g., shadow DOM) & make all behavior consistent with that model. |
TPAC F2F WebPlat: Discussed this topic. We may want a flag to control this since author defined custom elements may also want this behavior. But we've decided that this is probably best discussed in the CSS WG. |
FWIW, I just wrote https://bugzilla.mozilla.org/show_bug.cgi?id=1308080 which moves Gecko to use Shadow DOM. I want to discuss with @MatsPalmgren / @bzbarsky and co, in particular, since doing that would inmediately fix problems related with the magic way boxes are suppressed in |
Since this hasn't really become more (or less) of a problem I'm inclined to close this. Note that #4746 further formalizes the shadow tree behavior of |
Fieldset is defined in terms of the rendering; details is defined in terms of a shadow DOM like thing.
These are different when ::before and ::after are involved, because those are not placed in slots in shadow DOM; they get stuck into the rendering tree at the last minute after flattened tree construction is done.
As a result, per spec as currently written, ::before and ::after on a
<details>
will not be hidden like the normal non-summary DOM kids are and the ::before will render before the summary. But ::before and ::after on a<fieldset>
will behave quite differently, with the ::before going into the fieldset rendering area, not before the legend.It's not clear to me that this is actually purposeful; I suspect the "just use a shadow tree" thing here was written before shadow DOM had its current shape. It would make a lot more sense to me in terms of resulting behavior to have the ::before/::after of a
<details>
treated like its other non-summary kids.The text was updated successfully, but these errors were encountered: