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

> 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