Skip to content

Exception "NodeFilter is not defined" #101

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

Open
arekdygas opened this issue Mar 17, 2025 · 0 comments
Open

Exception "NodeFilter is not defined" #101

arekdygas opened this issue Mar 17, 2025 · 0 comments
Labels
Milestone

Comments

@arekdygas
Copy link
Contributor

arekdygas commented Mar 17, 2025

I'm trying to create NodeIterator object using the following code

var config = Configuration.Default.WithJs();
var context = BrowsingContext.New(config);
var document = await context.OpenAsync(req => req.Content("")).ConfigureAwait(false);
document.ExecuteScript("document.createNodeIterator(document.body, NodeFilter.SHOW_ELEMENT, null)");

Running it causes the exception Jint.Runtime.JavaScriptException: 'NodeFilter is not defined' I see that FilterSettings enum has [DomName("NodeFilter")] attribute, and yet it is not visible in JS.

I tried to check where other DomName attributes are resolved and that led me to the CreatorCache, where enums and classes are treated in a different way, which might explain the problem. But being totally new to AngleSharp and AngleSharp.JS, maybe I miss something, e.g. some configuration switch, which forces NodeFilter to be registered in JS?

Versions:
AngleSharp & AngleSharp.JS: master
Jint: 4.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants