4 ms·
It's easy to cook up a syntax for selecting parents. The hard part is implementing it efficiently. It requires browsers to scan more of the DOM tree when elemen
by tlb 15y ago
It's easy to cook up a syntax for selecting parents. The hard part is implementing it efficiently. It requires browsers to scan more of the DOM tree when elements are changed. I expect it to be one of the (many) parts of CSS that are avoided by websites that want to render quickly.
- snookca 15y agoExactly. And just because there's a draft specification, doesn't mean browsers will implement it.
- masklinn 15y agoI'm not sure, CSS selectors are already matched left-to-right so you're not scanning more stuff, it's just that you're selecting an other level of your match tree. ul > li > p ul > $li > p have the same matching complexity: the browser finds all p on the page, then checks if their parent is a li, then checks if that parent is a ul. The difference (which may or may not require significant work) is that before the check acted as a filter on the originally matched object, whereas now there's a transform/translation.
- deleted 15y ago[deleted]
- masklinn 15y agos/left-to-right/right-to-left/ of course