Advertisement
Advertisement
β‘ Community Insights
Discussion Sentiment
100% Positive
Analyzed from 423 words in the discussion.
Trending Topics
#css#selectors#xpath#https#php#dom#nice#things#pyastgrep#syntax
Discussion Sentiment
Analyzed from 423 words in the discussion.
Trending Topics
Discussion (12 Comments)Read Original on HackerNews
It's a shame that because CSS is still primarily for browser use and styling, we don't get nice things like the ability to select based on text content like we can with XPath. My understanding is that this was proposed but didn't make it into the spec because it could lead to performance issues in a browser rendering context.
[1] https://speakerdeck.com/keyvan/parsing-html-with-php-8-dot-4...
https://developer.mozilla.org/en-US/docs/Web/API/Document/ev...
e.g.:
pyastgrep --css 'Call > func > Name#main'
It was a joke but I really like the way it pointed out how we copy and reapply patterns in different contexts and that might enable unexpected things.
> we copy and reapply patterns in different contexts and that might enable unexpected things
yeah, that's exactly what I am trying to do here. Mostly it doesn't go anywhere, but it's interesting for the hacker spirit within me :)
For instance, currently you can conditionally change a parent based on its children. For example, this `pre` could either have 16px or 0px of padding. Zero when its direct child is a `code` element.
The entire article doesn't seem to mention the existence of :has() which is rather surprising given how recently it was written. Not even in the footnotes.
I think the conclusion (which I may not have made clear enough) is less like "These are limitations of modern CSS which ought to be fixed" and more "Maybe a CSS-like syntax could be added to a Datalog-like system and that would be helpful for making it more accessible to more engineers, navigating tree-shaped data, etc"
thanks for the feedback, anyway!