[css-scoping] Clarification: behavior of display: hidden
or visibility: none
on a slot
in a shadow tree
#2903
Labels
display: hidden
or visibility: none
on a slot
in a shadow tree
#2903
Uh oh!
There was an error while loading. Please reload this page.
I believe this is the relevant spec section with regards to the display property of slots. This issue in the spec is also very relevant.
I've built a simple reproducer that hopefully speaks to my question.
I've been working with web components a good deal lately and I recently ran into a situation where I wanted to conditionally hide a slot. Instead of conditionally rendering it, I chose to conditionally set
visibility: hidden
on it. This worked, as I had expected it to, in both Chrome 67, Safari latest and Firefox 61 with shadowDOM turned on. However a coworker who hadn't upgraded Chrome yet noted that it didn't work. Looking back at recent versions of Chrome it appears that only in Chrome 67+ doesvisibility: hidden
ordisplay: none
hide a slot. This lead me to question how display works with CSS in the slot's tree because both behaviors seemed reasonable at first glance.The general question is something like: does the box generated by a slot, given a display property other than
contents
, include the children and, then does hiding that box hide the children. The note on line 482 seems to indicate that the behavior of the up to date browsers is correct. i.e. hiding the slot should hide the children.Thanks!
The text was updated successfully, but these errors were encountered: