percy-dom 0.11.0

A standalone Virtual DOM creation, diffing and patching implementation
Documentation
//! percy-dom provides a virtual dom implementation as well as an `html!` macro
//! that you can use to generate a virtual dom.
//!
//! The virtual dom works on both the client and server. On the client we'll render
//! to an `HtmlElement`, and on the server we render to a `String`.

#![deny(missing_docs)]

extern crate wasm_bindgen;

pub use wasm_bindgen::JsCast;
// Used so that `html!` calls work when people depend on this crate since `html!` needs
// access to `Closure` when creating event handlers.
pub use wasm_bindgen::prelude::Closure;

#[cfg(feature = "macro")]
html_macro::define_html_macro! {
    /// Build a [`VirtualNode`] from a token stream.
    ///
    /// ## Examples
    /// ```
    /// # use percy_dom::prelude::*;
    /// use percy_dom::html;
    ///
    /// let div = html! { <div> Hello, world. </div> };
    /// ```
    ///
    /// [`VirtualNode`]: [`percy_dom::VirtualNode`]
    html!
    real_dom = $crate::prelude::__html_macro_helpers__::web_sys::Window,

    calls = $crate::prelude::__html_macro_helpers__::html_macro::html_with_config,
}

pub use virtual_node::*;

pub use crate::diff::*;
pub use crate::patch::*;

pub use self::pdom::PercyDom;

mod diff;
mod patch;
mod pdom;

pub mod render;
pub mod single_page_app;

/// Exports structs and macros that you'll almost always want access to in a virtual-dom
/// powered application
pub mod prelude {
    // TODO: look through this prelude and remove anything that isn't necessary.

    pub use std::vec::IntoIter;

    pub use wasm_bindgen::prelude::Closure;

    pub use virtual_node::{EventAttribFn, IterableNodes, View};

    #[cfg(feature = "macro")]
    pub use html;

    pub use crate::VirtualNode;
    pub use crate::VirtualNodeWebSys;
    pub use crate::pdom::PercyDom;

    // Used by the html-macro crate.
    #[doc(hidden)]
    pub mod __html_macro_helpers__ {
        pub use html_macro;
        pub use virtual_node::event;
        pub use web_sys;
    }
}