Re: [csswg-drafts] [selectors] Pseudo class to indicated when a slot has content (#6867)

Now that I think of it, it's not just `:empty` that could come in handy, but also `:has()`. If I want to hide a slot that has no slotted node *and* no default content, I could achieve it with

```css
slot:not(:has(*)):not(:has-slotted(*)) {
  display: none;
}
```

(`:empty` could be useful when there's just default *text* as content, like `<slot>Hello</slot>`... alas, it's brittle enough that it'd fail with just some whitespace.) `:has` and `:has-slotted` should cover all the basic uses. For example, if we have something like this, where that content can be wither passed as an attribute (for simple text) or as slotted content (for HTML content):

```html
<slot name="title">${this.cardTitle}</slot>
```

I wasn't aware that default slot content is returned by `.assignedElements({flatten: true})`, as considering it "assigned" to any slot seems counter-intuitive to me. All in all, I'm not sure that trying to mimic the behavior of a JS method would make sense here.

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 6 February 2023 16:50:42 UTC