3 ms·
A lot of the comments on the post about :has complain that browsers haven't implemented it yet. The reason it hasn't been implemented is (probably) that it's a
by Manishearth 10y ago
A lot of the comments on the post about :has complain that browsers haven't implemented it yet.
The reason it hasn't been implemented is (probably) that it's a big perf footgun (not because of laziness). It essentially doubles the amount of work you need to do in applying the cascade. I suspect some browsers implement it internally anyway, but leave it off for web content.
I don't remember the exact circumstances, but a month ago we were discussing some optimizations in Servo (which has parallel styling, making `:has` even worse), and often my thoughts would be "thank god :has doesn't exist", because it would often destroy the premise of the optimization.
I'm sure that optimizations can be done so that pages without :has are unaffected and pages with :has aren't affected as much, but how much is enough?
So I'm skeptical if it will ever make it. I'm not involved in the discussions here so I don't know what the current status is.
I mean, I've often felt the need for :has. I wish we could have it. I'm not sure if it's a good idea taking perf into consideration.
- Senji 10y agoI've used :has in uBlock filter declarations and it's perfect.(uBlock implements its own :has for its filters) It should be relatively trivial to isolate the elements targeted by :has and incur the performance penalty only for them instead of the whole dom.
- Manishearth 10y ago> relatively trivial No, that's the point, it isn't, because of various optimizations it turns off. I need to think about exactly what they were, but it's not as simple as isolating the has selectors.