Decouple virtual-node from web-sys - #213
Merged
Merged
Conversation
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.
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.
This commit makes the
VirtualNodetype use a newly introduced generictrait RealDomfor its events.Before this commit,
web_sys::Eventwas 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 tocrates/html-macro.This new macro can be used to create a new
html!macro withconfigured behavior.
For example,
create_html_macro!can create a macro that under the hoodcalls
arbitrary::path::to::html_with_config.These new
create_html_macro!andhtml_with_config!macros give usersmore control over how the
html!macro works, allowing us to continuefurther decoupling the
html!macro from ourvirtual-nodecrate.The motivating use case for this commit is that I want to start using
the
html!macro andVirtualNodein an application that does not runin a web browser.
This application has a custom simulated event handler system. So, I
needed
VirtualNodeto support defining events that do not useweb_sys, and I needed thehtml!macro to support producingVirtualNodes that are decoupled fromweb-sys.This commit solves these problems.