1//! The `dodrio` virtual DOM.
6//! use dodrio::{bumpalo, Attribute, Node, Render, RenderContext};
7//! use wasm_bindgen::UnwrapThrowExt;
9//! /// A component that greets someone.
10//! pub struct Hello<'who> {
14//! impl<'who> Hello<'who> {
15//! /// Construct a new `Hello` component that greets the given `who`.
16//! pub fn new(who: &str) -> Hello {
21//! impl<'who> Render for Hello<'who> {
22//! fn render<'a>(&self, cx: &mut RenderContext<'a>) -> Node<'a> {
23//! use dodrio::builder::*;
25//! let id = bumpalo::format!(in cx.bump, "hello-{}", self.who);
26//! let who = bumpalo::collections::String::from_str_in(self.who, cx.bump).into_bump_str();
29//! .attr("id", id.into_bump_str())
30//! .on("click", |root, _vdom, _event| {
31//! let hello = root.unwrap_mut::<Hello>();
33//! .expect_throw("should have a `Window` on the Web")
34//! .alert_with_message(hello.who);
49#![deny(missing_docs, missing_debug_implementations)]
51// Re-export the `bumpalo` crate.
55 if #[cfg(feature = "log")] {
64// A macro to expose items unstably, only for internal/testing usage.
66 if #[cfg(feature = "xxx-unstable-internal-use-only")] {
67 macro_rules! pub_unstable_internal {
68 ( $(#[$attr:meta])* pub(crate) $( $thing:tt )* ) => {
75 macro_rules! pub_unstable_internal {
76 ( $(#[$attr:meta])* pub(crate) $( $thing:tt )* ) => {
78 pub(crate) $( $thing )*
84// Only `pub` so that the wasm-bindgen bindings work.
100// Re-export items at the top level.
101pub use self::cached::Cached;
102pub use self::node::{Attribute, Listener, Node, NodeKey};
103pub use self::render::{Render, RootRender};
104pub use self::render_context::RenderContext;
105pub use self::vdom::{Vdom, VdomWeak};
108 if #[cfg(all(target_arch = "wasm32", not(feature = "xxx-unstable-internal-use-only")))] {
109 use wasm_bindgen::__rt::WasmRefCell as RefCell;
111 use std::cell::RefCell;
115// Polyfill some Web stuff for benchmarking...
117 if #[cfg(all(feature = "xxx-unstable-internal-use-only", not(target_arch = "wasm32")))] {
118 /// An element node in the physical DOM.
119 pub type Element = ();
121 pub(crate) type EventsTrampoline = ();
123 /// An element node in the physical DOM.
124 pub type Element = web_sys::Element;
126 pub(crate) type EventsTrampoline = wasm_bindgen::closure::Closure<Fn(web_sys::Event, u32, u32)>;
131 if #[cfg(feature = "xxx-unstable-internal-use-only")] {
132 pub use self::cached_set::{CachedSet};
133 pub use self::node::{ElementNode, NodeKind, TextNode};
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list