Skip to content

Decouple virtual-node from web-sys - #213

Merged
chinedufn merged 1 commit into
masterfrom
decouple-virtual-node-from-web-sys
Aug 7, 2026
Merged

Decouple virtual-node from web-sys#213
chinedufn merged 1 commit into
masterfrom
decouple-virtual-node-from-web-sys

Conversation

@chinedufn

Copy link
Copy Markdown
Owner

This commit makes the VirtualNode type use a newly introduced generic
trait RealDom for its events.
Before this commit, web_sys::Event was used to represent events.

This change allows events to be handled in applications that do not use
web-sys.


This commit also introduces a create_html_macro! macro to
crates/html-macro.
This new macro can be used to create a new html! macro with
configured behavior.
For example, create_html_macro! can create a macro that under the hood
calls arbitrary::path::to::html_with_config.
These new create_html_macro! and html_with_config! macros give users
more control over how the html! macro works, allowing us to continue
further decoupling the html! macro from our virtual-node crate.


The motivating use case for this commit is that I want to start using
the html! macro and VirtualNode in an application that does not run
in a web browser.
This application has a custom simulated event handler system. So, I
needed VirtualNode to support defining events that do not use
web_sys, and I needed the html! macro to support producing
VirtualNodes that are decoupled from web-sys.
This commit solves these problems.

This commit makes the `VirtualNode` type use a newly introduced generic
`trait RealDom` for its events.
Before this commit, `web_sys::Event` was used to represent events.

This change allows events to be handled in applications that do not use
`web-sys`.

---

This commit also introduces a `create_html_macro!` macro to
`crates/html-macro`.
This new macro can be used to create a new `html!` macro with
configured behavior.
For example, `create_html_macro!` can create a macro that under the hood
calls `arbitrary::path::to::html_with_config`.
These new `create_html_macro!` and `html_with_config!` macros give users
more control over how the `html!` macro works, allowing us to continue
further decoupling the `html!` macro from our `virtual-node` crate.

---

The motivating use case for this commit is that I want to start using
the `html!` macro and `VirtualNode` in an application that does not run
in a web browser.
This application has a custom simulated event handler system. So, I
needed `VirtualNode` to support defining events that do not use
`web_sys`, and I needed the `html!` macro to support producing
`VirtualNode`s that are decoupled from `web-sys`.
This commit solves these problems.
@chinedufn
chinedufn merged commit deefd4f into master Aug 7, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant