diff --git a/Cargo.toml b/Cargo.toml index 176be176f..bc17f9cea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus" -version = "0.1.4" +version = "0.1.5" authors = ["Jonathan Kelley"] edition = "2018" description = "Core functionality for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" @@ -11,13 +11,13 @@ documentation = "https://dioxuslabs.com" keywords = ["dom", "ui", "gui", "react", "wasm"] [dependencies] -dioxus-core = { path = "./packages/core", version = "^0.1.4" } -dioxus-html = { path = "./packages/html", version = "^0.1.1", optional = true } -dioxus-core-macro = { path = "./packages/core-macro", version = "^0.1.3", optional = true } -dioxus-hooks = { path = "./packages/hooks", version = "^0.1.4", optional = true } +dioxus-core = { path = "./packages/core", version = "^0.1.6" } +dioxus-html = { path = "./packages/html", version = "^0.1.3", optional = true } +dioxus-core-macro = { path = "./packages/core-macro", version = "^0.1.5", optional = true } +dioxus-hooks = { path = "./packages/hooks", version = "^0.1.5", optional = true } -dioxus-web = { path = "./packages/web", version = "^0.0.2", optional = true } -dioxus-desktop = { path = "./packages/desktop", version = "^0.1.1", optional = true } +dioxus-web = { path = "./packages/web", version = "^0.0.3", optional = true } +dioxus-desktop = { path = "./packages/desktop", version = "^0.1.3", optional = true } dioxus-ssr = { path = "./packages/ssr", version = "0.1.1", optional = true } # dioxus-router = { path = "./packages/router", optional = true } diff --git a/packages/core-macro/Cargo.toml b/packages/core-macro/Cargo.toml index 95ec58e0c..24aa07ee4 100644 --- a/packages/core-macro/Cargo.toml +++ b/packages/core-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-core-macro" -version = "0.1.4" +version = "0.1.5" authors = ["Jonathan Kelley"] edition = "2021" description = "Core macro for Dioxus Virtual DOM" diff --git a/packages/core-macro/src/rsx/element.rs b/packages/core-macro/src/rsx/element.rs index cb0b7bdaa..71e0e90ac 100644 --- a/packages/core-macro/src/rsx/element.rs +++ b/packages/core-macro/src/rsx/element.rs @@ -204,9 +204,9 @@ impl ToTokens for Element { tokens.append_all(quote! { __cx.element( dioxus_elements::#name, - [ #(#listeners),* ], - [ #(#attr),* ], - [ #(#children),* ], + __cx.bump().alloc([ #(#listeners),* ]), + __cx.bump().alloc([ #(#attr),* ]), + __cx.bump().alloc([ #(#children),* ]), #key, ) }); diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 725f111a8..1c37020f7 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-core" -version = "0.1.5" +version = "0.1.6" authors = ["Jonathan Kelley"] edition = "2018" description = "Core functionality for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 6c2b3f0b7..0acb08829 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -75,7 +75,7 @@ pub enum VNode<'src> { /// Example {} /// } /// ``` - Fragment(VFragment<'src>), + Fragment(&'src VFragment<'src>), /// Component nodes represent a mounted component with props, children, and a key. /// @@ -156,15 +156,12 @@ impl<'src> VNode<'src> { // Create an "owned" version of the vnode. pub fn decouple(&self) -> VNode<'src> { - match self { - VNode::Text(t) => VNode::Text(*t), - VNode::Element(e) => VNode::Element(*e), - VNode::Component(c) => VNode::Component(*c), - VNode::Placeholder(a) => VNode::Placeholder(*a), - VNode::Fragment(f) => VNode::Fragment(VFragment { - children: f.children, - key: f.key, - }), + match *self { + VNode::Text(t) => VNode::Text(t), + VNode::Element(e) => VNode::Element(e), + VNode::Component(c) => VNode::Component(c), + VNode::Placeholder(a) => VNode::Placeholder(a), + VNode::Fragment(f) => VNode::Fragment(f), } } } @@ -447,19 +444,14 @@ impl<'a> NodeFactory<'a> { })) } - pub fn element( + pub fn element( &self, el: impl DioxusElement, - listeners: L, - attributes: A, - children: V, + listeners: &'a [Listener<'a>], + attributes: &'a [Attribute<'a>], + children: &'a [VNode<'a>], key: Option, - ) -> VNode<'a> - where - L: 'a + AsRef<[Listener<'a>]>, - A: 'a + AsRef<[Attribute<'a>]>, - V: 'a + AsRef<[VNode<'a>]>, - { + ) -> VNode<'a> { self.raw_element( el.tag_name(), el.namespace(), @@ -470,29 +462,15 @@ impl<'a> NodeFactory<'a> { ) } - pub fn raw_element( + pub fn raw_element( &self, tag_name: &'static str, namespace: Option<&'static str>, - listeners: L, - attributes: A, - children: V, + listeners: &'a [Listener<'a>], + attributes: &'a [Attribute<'a>], + children: &'a [VNode<'a>], key: Option, - ) -> VNode<'a> - where - L: 'a + AsRef<[Listener<'a>]>, - A: 'a + AsRef<[Attribute<'a>]>, - V: 'a + AsRef<[VNode<'a>]>, - { - let listeners: &'a L = self.bump.alloc(listeners); - let listeners = listeners.as_ref(); - - let attributes: &'a A = self.bump.alloc(attributes); - let attributes = attributes.as_ref(); - - let children: &'a V = self.bump.alloc(children); - let children = children.as_ref(); - + ) -> VNode<'a> { let key = key.map(|f| self.raw_text(f).0); VNode::Element(self.bump.alloc(VElement { @@ -574,10 +552,10 @@ impl<'a> NodeFactory<'a> { if nodes.is_empty() { VNode::Placeholder(self.bump.alloc(VPlaceholder { id: empty_cell() })) } else { - VNode::Fragment(VFragment { + VNode::Fragment(self.bump.alloc(VFragment { children: nodes.into_bump_slice(), key: None, - }) + })) } } @@ -613,10 +591,10 @@ impl<'a> NodeFactory<'a> { ); } - VNode::Fragment(VFragment { + VNode::Fragment(self.bump.alloc(VFragment { children, key: None, - }) + })) } } @@ -639,10 +617,10 @@ impl<'a> NodeFactory<'a> { } else { let children = nodes.into_bump_slice(); - Some(VNode::Fragment(VFragment { + Some(VNode::Fragment(self.bump.alloc(VFragment { children, key: None, - })) + }))) } } } diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index e533f3bf9..1b8ead959 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-desktop" -version = "0.1.2" +version = "0.1.3" authors = ["Jonathan Kelley"] edition = "2018" description = "Dioxus VirtualDOM renderer for a remote webview instance" @@ -12,7 +12,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dioxus-core = { path = "../core", version = "^0.1.3", features = ["serialize"] } +dioxus-core = { path = "../core", version = "^0.1.6", features = ["serialize"] } argh = "0.1.4" serde = "1.0.120" serde_json = "1.0.61" diff --git a/packages/hooks/Cargo.toml b/packages/hooks/Cargo.toml index e1994bfb2..d85424f04 100644 --- a/packages/hooks/Cargo.toml +++ b/packages/hooks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-hooks" -version = "0.1.4" +version = "0.1.5" authors = ["Jonathan Kelley"] edition = "2018" description = "Dioxus VirtualDOM renderer for a remote webview instance" @@ -12,4 +12,4 @@ keywords = ["dom", "ui", "gui", "react", "wasm"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dioxus-core = { path = "../../packages/core", version = "0.1.5" } +dioxus-core = { path = "../../packages/core", version = "^0.1.6" } diff --git a/packages/html/Cargo.toml b/packages/html/Cargo.toml index 93e62ba70..872f27d2b 100644 --- a/packages/html/Cargo.toml +++ b/packages/html/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-html" -version = "0.1.2" +version = "0.1.3" authors = ["Jonathan Kelley"] edition = "2018" description = "HTML Element pack for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" @@ -11,7 +11,7 @@ documentation = "https://docs.rs/dioxus" keywords = ["dom", "ui", "gui", "react", "wasm"] [dependencies] -dioxus-core = { path = "../core", version = "^0.1.4" } +dioxus-core = { path = "../core", version = "^0.1.6" } serde = { version = "1", features = ["derive"], optional = true } serde_repr = { version = "0.1", optional = true } diff --git a/packages/router/Cargo.toml b/packages/router/Cargo.toml index 0588a2038..158a233fa 100644 --- a/packages/router/Cargo.toml +++ b/packages/router/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dioxus-core = { path = "../core", version = "^0.1.3", default-features = false } +dioxus-core = { path = "../core", version = "^0.1.6", default-features = false } dioxus-html = { path = "../html", version = "^0.1.0", default-features = false } dioxus-core-macro = { path = "../core-macro", version = "^0.1.2" } diff --git a/packages/ssr/Cargo.toml b/packages/ssr/Cargo.toml index 0dda9d5e6..1aa0c77ea 100644 --- a/packages/ssr/Cargo.toml +++ b/packages/ssr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-ssr" -version = "0.1.1" +version = "0.1.2" authors = ["Jonathan Kelley"] edition = "2018" description = "Dioxus render-to-string" @@ -13,7 +13,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dioxus-core = { path = "../core", version = "^0.1.3", features = ["serialize"] } +dioxus-core = { path = "../core", version = "^0.1.6", features = ["serialize"] } [dev-dependencies] diff --git a/packages/web/Cargo.toml b/packages/web/Cargo.toml index 4da9ecc50..83dc93485 100644 --- a/packages/web/Cargo.toml +++ b/packages/web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-web" -version = "0.0.2" +version = "0.0.3" authors = ["Jonathan Kelley"] edition = "2018" description = "Dioxus VirtualDOM renderer for the web browser using websys" @@ -11,7 +11,7 @@ documentation = "https://dioxuslabs.com" keywords = ["dom", "ui", "gui", "react", "wasm"] [dependencies] -dioxus-core = { path = "../core", version = "^0.1.4" } +dioxus-core = { path = "../core", version = "^0.1.6" } dioxus-html = { path = "../html", version = "^0.1.1" } js-sys = "0.3" wasm-bindgen = { version = "0.2.78", features = ["enable-interning"] } diff --git a/packages/web/src/dom.rs b/packages/web/src/dom.rs index 645bae76a..655b6c8c5 100644 --- a/packages/web/src/dom.rs +++ b/packages/web/src/dom.rs @@ -13,7 +13,7 @@ use std::{any::Any, fmt::Debug, rc::Rc, sync::Arc}; use wasm_bindgen::{closure::Closure, JsCast}; use web_sys::{ CssStyleDeclaration, Document, Element, Event, HtmlElement, HtmlInputElement, - HtmlOptionElement, HtmlTextAreaElement, Node, NodeList, + HtmlOptionElement, HtmlTextAreaElement, Node, }; use crate::{nodeslab::NodeSlab, WebConfig}; @@ -49,7 +49,7 @@ impl WebsysDom { pub fn new(root: Element, cfg: WebConfig, sender_callback: Rc) -> Self { let document = load_document(); - let mut nodes = NodeSlab::new(2000); + let nodes = NodeSlab::new(2000); let listeners = FxHashMap::default(); // re-hydrate the page - only supports one virtualdom per page