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
{{ message }}
Repository navigation
Commit 8bc3c10
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/tutorials/01-API.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ The package targets `netstandard2.0`, `net462`, `net472`, `net8.0` and `net10.0`
12
12
13
13
| Type / member | Namespace | Purpose |
14
14
| --- | --- | --- |
15
-
|`WithJs()`, `WithJs(JsScriptingOptions)`|`AngleSharp`| Registers the JavaScript engine and its auxiliary services. |
15
+
|`WithJs()`, `WithJs(JsScriptingOptions)`, `WithJs(DomRegistration)`|`AngleSharp`| Registers the JavaScript engine and its auxiliary services. |
16
16
|`WithEventLoop()` and overloads |`AngleSharp`| Registers the event loop that runs scripts, timers and callbacks. |
17
17
|`WithConsoleLogger(Func<IBrowsingContext, IConsoleLogger>)`|`AngleSharp`| Routes `console.*` output to your code. |
18
18
|`ExecuteScript(document, code, type, sourceUrl)`|`AngleSharp.Js`| Runs JavaScript in the document's engine and returns the result. |
@@ -50,6 +50,22 @@ Registers:
50
50
51
51
Calling `WithJs` does **not** register an event loop or a loader. Most documents that run scripts need both (see `WithEventLoop` and AngleSharp's `WithDefaultLoader`).
52
52
53
+
### `WithJs(DomRegistration registration)`
54
+
55
+
By default the engine finds the DOM exposed to scripts by reflecting over the DOM attributes of the AngleSharp libraries behind the services of the browsing context. Given a registration (also `JsScriptingOptions.DomRegistration`), it exposes exactly what is registered instead: nothing is reflected over, which is what a trimmed or natively compiled (AoT) application needs.
56
+
57
+
Each library ships the registration of its DOM, generated at build time from its DOM attributes: `CssDom.Register` of AngleSharp.Css, `IoDom.Register` of AngleSharp.Io, and so on. The DOM of AngleSharp itself (`CoreDom`) and of this library are always registered first, so a registration only names the further libraries in use:
A library that is a service of the context but not part of the registration is not exposed to scripts. An application can add its own types with `[DomName]` attributes and `[assembly: GenerateDomRegistration("MyApp.AppDom")]`, or declare members by hand on the `DomRegistry` (see AngleSharp's documentation).
0 commit comments