-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
ArrayHandle null trying to enumerate <li/> menu items #54
Comments
Another data point for you, for giggles I tried the following. var liContext = await context.QuerySelectorAllAsync<HtmlListItemElement>(S.Li); And it "works". Sort it, but it will not work for us, I think, because these are "all" of the Maybe there is a better way to get those children, I do not know. |
Note that the |
After poking around a bit and exploring the query and child paths available, this one will work, and I rather prefer it actually. Seems to be focused on the direct child elements of the specified type, which is perfect, just what we need. Not that the other one ought not to work, in principle, but this one does as well, FWIW. var ulMenu = await context.QuerySelectorAsync<HtmlUnorderedListElement>(S.Menu);
var liServerItems = await (await ulMenu.GetChildrenAsync<HtmlListItemElement>()).ToArrayAsync();
// ...and on from there, drilled through a couple other use cases, including another nested <li/>, also successfully. The only thing I dislike about it, the lack of selector comprehension, in the event we need to provide more discernment there, but for what we are doing, I think it will be sufficient. |
Your code looks fine, likely it's a bug. The other var arrayHandle = await Handle.EvaluateFunctionHandleAsync(
"(element, selector) => element.querySelectorAll(selector)",
selector).ConfigureAwait(false);
var properties = await arrayHandle.GetPropertiesAsync().ConfigureAwait(false);
await arrayHandle.DisposeAsync().ConfigureAwait(false);
return properties.Select(kvp => kvp.Value.ToDomHandle<T>()).ToArray();
You know |
Awesome; duly noted, for future reference. Thank you... 🍻 |
We should fix the current implementation. |
Cool. That'd be great, overall in general. Although, I do have a workaround, which I think is a bit better suited to the target DOM in question. |
To frame the opportunity at hand, I tried the same thing in the Chrome dev tools in browser, and I get the range back that I am expecting.
In my calling code:
I'm doing that correctly, yes? I want all the
<li/>
elements child to theulMenu
.Everything else being equal, I promise you it "should be" returning valid elements, from the Chrome console:
There is obviously more within each of these elements, abbreviated for brevity.
The text was updated successfully, but these errors were encountered: