feat: expose dom option on the Node binding's build() API#303
Merged
mohamedmansour merged 1 commit intoMay 19, 2026
Merged
Conversation
The CLI and Rust API already expose DomStrategy::Light via --dom light and BuildOptions { dom, .. }, but the napi-rs Node binding's build() hardcoded DomStrategy::Shadow and gave JS callers no way to opt into light DOM.
Add an optional 'dom' field to JsBuildOptions that parses through the existing DomStrategy::FromStr impl (accepting 'shadow' and 'light') and defaults to DomStrategy::default() (Shadow) when omitted. Existing callers see byte-for-byte identical output; new callers can pass { dom: 'light' } to opt into light DOM rendering, which is the supported path for component output that needs to compose correctly when injected after page load.
Adds tests for light DOM, shadow DOM, and an invalid dom value, and documents the field in docs/guide/integrations/node.md.
mohamedmansour
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Exposes the
dombuild option on@microsoft/webui's napi-rs Node binding so JavaScript callers can opt into light DOM rendering.Why
The CLI already supports
webui build --dom lightand the Rust API already supportsBuildOptions { dom: DomStrategy::Light, .. }. The Node binding's runtimebuild()function, however, hardcodedDomStrategy::Shadowand gave JS callers no way to select light DOM.Light DOM rendering is the supported path for component output that needs to compose correctly when injected after page load - for example, into a streaming response body whose later HTML lands via
innerHTMLand therefore cannot rely on DSD auto-attachment. Thefast-v3plugin emits only HTML comment markers (<!--fe:b-->,<!--fe:/b-->,<!--fe:r-->,<!--fe:/r-->) anddata-fe="N"attributes, all of which work identically in light DOM, so--dom light --plugin fast-v3is a fully supported combination.What changed
crates/webui-node/src/lib.rsJsBuildOptionsgainspub dom: Option<String>.build()parses the field via the existingwebui::DomStrategy::FromStrimpl (accepts"shadow"and"light") and falls back towebui::DomStrategy::default()(Shadow) when omitted.dom: webui::DomStrategy::ShadowinBuildOptions.test_build_with_light_dom_omits_shadow_root_templatetest_build_with_shadow_dom_emits_shadow_root_templatetest_build_invalid_domdocs/guide/integrations/node.mddomrow to theBuildOptionsreference table, matching the existing CLI documentation.Non-breaking
Option<String>. Omitted by every existing caller -> falls back toDomStrategy::default()(Shadow) -> byte-for-byte identical output.DomStrategyis already in the proto schema).Validation
cargo test -p microsoft-webui-node --lib: 24 passed.cargo xtask check: license-headers, fmt, clippy all green. (The proto-drift step requiresprotocwhich isn't available in my local env; this PR touches no.protofiles.)