1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
//! The `dodrio` virtual DOM. //! //! ## Example //! //! ```no_run //! use dodrio::{bumpalo::Bump, Attribute, Node, Render}; //! use wasm_bindgen::UnwrapThrowExt; //! //! /// A component that greets someone. //! pub struct Hello<'who> { //! who: &'who str, //! } //! //! impl<'who> Hello<'who> { //! /// Construct a new `Hello` component that greets the given `who`. //! pub fn new(who: &str) -> Hello { //! Hello { who } //! } //! } //! //! impl<'who> Render for Hello<'who> { //! fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump> //! where //! 'a: 'bump, //! { //! use dodrio::builder::*; //! //! let id = bumpalo::format!(in bump, "hello-{}", self.who); //! //! div(bump) //! .attr("id", id.into_bump_str()) //! .on("click", |root, _vdom, _event| { //! let hello = root.unwrap_mut::<Hello>(); //! web_sys::window() //! .expect_throw("should have a `Window` on the Web") //! .alert_with_message(hello.who); //! }) //! .children([ //! text("Hello, "), //! strong(bump) //! .children([ //! text(self.who), //! text("!"), //! ]) //! .finish(), //! ]) //! .finish() //! } //! } //! ``` #![deny(missing_docs, missing_debug_implementations)] // Re-export the `bumpalo` crate. pub use bumpalo; cfg_if::cfg_if! { if #[cfg(feature = "log")] { #[macro_use] extern crate log; } else { #[macro_use] mod logging; } } // Only `pub` so that the wasm-bindgen bindings work. #[doc(hidden)] pub mod change_list; mod cached; mod events; mod node; mod render; mod vdom; pub mod builder; // Re-export items at the top level. pub use self::cached::Cached; pub use self::node::{Attribute, ElementNode, Listener, ListenerCallback, Node, TextNode}; pub use self::render::{Render, RootRender}; pub use self::vdom::{Vdom, VdomWeak};