-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails with has and direct child selector #43
Comments
I just noticed an alternative way to do this, using the var selected = context.querySelectorAll(':scope > img'); Unfortunately, Cascadia doesn't support this psuedo-class. Is there an existing way to achieve what I want? |
No, Cascadia has no concept of scope at all. A selector either matches an element or it doesn't. There is no provision for matching an element relative to a given scope. In this sense it's like the Selectors "live profile"—but I copied |
In the context of goquery it would be really useful if one could do something like: table.Find(":scope > tbody > tr > th") To find only I made an goquery issue as well: PuerkitoBio/goquery#414 |
I was thinking, |
Yes, that's what it would be. But Cascadia selectors don't know where they start. The basic interface of the Cascadia package is Matcher: type Matcher interface {
Match(n *html.Node) bool
} A Matcher can be called on to match a node from anywhere in the page, in no particular order. It has no concept of a "starting point". |
But it would work for |
No, because those are implemented as wrappers around Match. Almost everything in Cascadia is built around the Match interface. Support for scope would require such an extensive rewrite that the result wouldn't really be Cascadia any more. It would be an all-new CSS selector package. |
Just so I understand this thread, support for |
Right. |
Problem
Cascadia seems to fail with the
has
psudo-class and a direct child selectorFrom MDN
Cascadia test
Result
selector_test.go:651: error compiling "a:has(> img)": expected identifier, found > instead
Is there any chance to get this implemented?
Thanks!
The text was updated successfully, but these errors were encountered: