W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2018

Re: [csswg-drafts] [selectors-4] Add a count to :has() (#1547)

From: Eric Willigers via GitHub <sysbot+gh@w3.org>
Date: Fri, 07 Dec 2018 05:09:10 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-445124500-1544159349-sysbot+gh@w3.org>
> However, this doesn't allow styling of the parent based on the number of children.

Note that `:has` [cannot](https://drafts.csswg.org/selectors-4/#profiles) be used in style rules. It can be used by script:

```
const parents = document.querySelectorAll('a:has(> img)');
for (let parent of parents) {
  const numChildren = parent.querySelectorAll('* > img').length;
  if (numChildren > ...)
    parent.style. ... = ...;
  else
    ...
}
```


-- 
GitHub Notification of comment by ewilligers
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1547#issuecomment-445124500 using your GitHub account
Received on Friday, 7 December 2018 05:09:12 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:40 UTC