You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<body><articleid="a"><div>First</div><div>Before<div>Nested</div>After</div><div>Last</div></article><articleid="b"><div>Some other article</div></article></body>
My goal is to scrape the first article and get its id and number of direct-child <div>s. Ignoring error handling, I could use something like:
There are a few issues with this code. The first one is that article:first-of-type is not the same as getting the first article match. In this case it's ok, but in general it's more brittle. The next one is that I am traversing more nodes that needed: I already have a reference to the first article and should be able to start the traversal from there with first_article.select.
The problem is that the > direct-child operator needs a left-side. How can I reference the current scope? More precisly, what should be the value of ??? in the following code?
let content_count = first_article.select(&Selector::parse("??? > div").unwrap()).count();
I tried to use the following values:
:root: Document root
:host: Shadow-element root
&: Sass sigil referring to the current scope
Is it possible to reference the current scope in the selector or is this behavior unsupported at all?
The text was updated successfully, but these errors were encountered:
Suppose I have the following HTML:
My goal is to scrape the first article and get its id and number of direct-child
<div>
s. Ignoring error handling, I could use something like:There are a few issues with this code. The first one is that
article:first-of-type
is not the same as getting the firstarticle
match. In this case it's ok, but in general it's more brittle. The next one is that I am traversing more nodes that needed: I already have a reference to the first article and should be able to start the traversal from there withfirst_article.select
.The problem is that the
>
direct-child operator needs a left-side. How can I reference the current scope? More precisly, what should be the value of???
in the following code?I tried to use the following values:
:root
: Document root:host
: Shadow-element root&
: Sass sigil referring to the current scopeIs it possible to reference the current scope in the selector or is this behavior unsupported at all?
The text was updated successfully, but these errors were encountered: