Closed mna closed 7 months ago
Yes, you're understanding it correctly. Cascadia selectors have no concept of context. They work like vanilla JavaScript, not like JQuery. To understand what I mean by that, open that HTML in a browser and type the following in the console:
tr0 = document.querySelector(".start > tbody > tr");
matches = tr0.querySelectorAll(".start > tbody > tr > td");
console.log(matches);
Thanks, makes sense. I'll make sure to document it clearly in goquery to manage expectations.
Hello Andy,
The following program returns the 2
<td>
nodes under the first<tr>
even though the selector gives the impression that it should look for a.start
class in the decendents of that<tr>
(and should not find any):Correct me if I'm wrong but I think it might be working as intended in Cascadia, even though it differs from what folks may be used to with jQuery, in that (IIUC) the selector is always started from the root of the document, but only descendents of the contextual node are returned (if they do match).
This has come up in the context of https://github.com/PuerkitoBio/goquery/issues/468, but after investigation and reading through some issues you closed, I have the feeling it is by design.
Thanks, Martin