diff --git a/Cargo.toml b/Cargo.toml index 804589ccd..9861524b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,12 @@ exclude = [ [dev-dependencies.criterion] version = "0.5.1" +default-features = false + +[package.metadata.docs.rs] +all-features = true +default-target = "wasm32-unknown-unknown" + [[bench]] name = "nodes_benchmark" diff --git a/crates/html-parser/src/lib.rs b/crates/html-parser/src/lib.rs index 14726ca6d..2b3e3f4d3 100644 --- a/crates/html-parser/src/lib.rs +++ b/crates/html-parser/src/lib.rs @@ -6,6 +6,7 @@ use rphtml::types::BoxDynError; use sauron_core::{ html::{attributes::*, lookup, *}, vdom::Node, + vdom::AttributeValue, }; use std::fmt; use std::io; diff --git a/crates/sauron-core/src/dom/dom_node.rs b/crates/sauron-core/src/dom/dom_node.rs index abef44b8e..1d0d03464 100644 --- a/crates/sauron-core/src/dom/dom_node.rs +++ b/crates/sauron-core/src/dom/dom_node.rs @@ -3,9 +3,9 @@ use crate::{ dom::{self, Application, Program}, dom::{document, window}, html, - html::attributes::{AttributeValue, Listener, SegregatedAttributes}, + html::attributes::{Listener, SegregatedAttributes}, vdom, - vdom::{Attribute, Leaf, NodeTrait}, + vdom::{Attribute, Leaf, NodeTrait, AttributeValue, }, }; use js_sys::Function; use crate::vdom::TreePath; diff --git a/crates/sauron-core/src/dom/events.rs b/crates/sauron-core/src/dom/events.rs index 656ab8ead..d9a4fb235 100644 --- a/crates/sauron-core/src/dom/events.rs +++ b/crates/sauron-core/src/dom/events.rs @@ -3,8 +3,7 @@ //! [0]: https://developer.mozilla.org/en-US/docs/Web/Events use crate::dom::{document, window, Event}; use crate::{ - html::attributes::AttributeValue, - vdom::{Attribute, Listener}, + vdom::{Attribute, Listener, AttributeValue}, }; use wasm_bindgen::JsCast; use crate::vdom; diff --git a/crates/sauron-core/src/html/attributes.rs b/crates/sauron-core/src/html/attributes.rs index 9a46193e8..b8608a524 100644 --- a/crates/sauron-core/src/html/attributes.rs +++ b/crates/sauron-core/src/html/attributes.rs @@ -3,11 +3,11 @@ //! [0]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes use std::borrow::Cow; use crate::vdom; +use crate::vdom::AttributeValue; pub use crate::{dom::Event, vdom::Attribute}; pub use attribute_macros::commons::*; pub use attribute_macros::*; -pub use attribute_value::AttributeValue; pub use listener::Listener; pub use special::{key, replace, skip, skip_criteria}; pub use style::Style; @@ -15,7 +15,6 @@ pub use value::Value; #[macro_use] mod attribute_macros; -mod attribute_value; mod listener; mod special; mod style; diff --git a/crates/sauron-core/src/html/attributes/attribute_macros.rs b/crates/sauron-core/src/html/attributes/attribute_macros.rs index bd11f5537..4c14f32f9 100644 --- a/crates/sauron-core/src/html/attributes/attribute_macros.rs +++ b/crates/sauron-core/src/html/attributes/attribute_macros.rs @@ -1,4 +1,5 @@ -use crate::html::attributes::{AttributeValue, Value}; +use crate::html::attributes::Value; +use crate::vdom::AttributeValue; use crate::vdom::attr; /// declare a function with the name corresponds to attribute name for easy usage in html elements @@ -104,7 +105,8 @@ macro_rules! declare_html_attributes_special{ /// common used html attributes pub mod commons { - use crate::html::attributes::{AttributeValue, Value}; + use crate::html::attributes::Value; + use crate::vdom::AttributeValue; use crate::vdom::attr; // List from html attributes // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes diff --git a/crates/sauron-core/src/svg/attributes.rs b/crates/sauron-core/src/svg/attributes.rs index 694ce1a8d..a966d7093 100644 --- a/crates/sauron-core/src/svg/attributes.rs +++ b/crates/sauron-core/src/svg/attributes.rs @@ -1,5 +1,6 @@ //! provides functions and macros for building svg attributes -use crate::html::attributes::{AttributeValue, Value}; +use crate::html::attributes::Value; +use crate::vdom::AttributeValue; pub use commons::*; use crate::vdom::{attr, attr_ns}; pub use special::*; diff --git a/crates/sauron-core/src/vdom.rs b/crates/sauron-core/src/vdom.rs index e42eef8db..97bd94b2d 100644 --- a/crates/sauron-core/src/vdom.rs +++ b/crates/sauron-core/src/vdom.rs @@ -5,7 +5,6 @@ //! All the code in this module are run in purely rust environment, that is there is NO code here //! involves accessing the real DOM. //! -pub use crate::html::attributes::AttributeValue; use crate::{dom::Event, html::attributes}; pub use leaf::Leaf; pub use node_trait::NodeTrait; @@ -19,9 +18,10 @@ pub use diff::{diff, diff_recursive}; pub use node::{ attribute::{ attr, attr_ns, group_attributes_per_name, merge_attributes_of_same_name, - Tag, KEY, Namespace, AttributeName, + Tag, KEY, Namespace, AttributeName, }, element, element_ns, fragment, leaf, node_list, Attribute, Element, Node, + AttributeValue, }; pub use patch::{Patch, PatchType, TreePath}; diff --git a/crates/sauron-core/src/vdom/map_msg.rs b/crates/sauron-core/src/vdom/map_msg.rs index 70cace078..433d8ab17 100644 --- a/crates/sauron-core/src/vdom/map_msg.rs +++ b/crates/sauron-core/src/vdom/map_msg.rs @@ -1,6 +1,5 @@ use crate::{ - html::attributes::AttributeValue, - vdom::{Attribute, Element, Listener, Node}, + vdom::{Attribute, Element, Listener, Node, AttributeValue}, }; diff --git a/crates/sauron-core/src/vdom/node.rs b/crates/sauron-core/src/vdom/node.rs index 349869fe1..70a793fbf 100644 --- a/crates/sauron-core/src/vdom/node.rs +++ b/crates/sauron-core/src/vdom/node.rs @@ -1,12 +1,15 @@ -use super::{AttributeName, Namespace, Tag, AttributeValue}; -pub use attribute::Attribute; +use super::{AttributeName, Namespace, Tag}; use std::fmt; use std::fmt::{Debug, Formatter}; -pub use element::Element; use crate::vdom::Leaf; use derive_where::derive_where; +pub use attribute::Attribute; +pub use element::Element; +pub use attribute_value::AttributeValue; + pub(crate) mod attribute; +pub(crate) mod attribute_value; mod element; /// represents a node in a virtual dom diff --git a/crates/sauron-core/src/vdom/node/attribute.rs b/crates/sauron-core/src/vdom/node/attribute.rs index 8a999f54c..9ac54a5c9 100644 --- a/crates/sauron-core/src/vdom/node/attribute.rs +++ b/crates/sauron-core/src/vdom/node/attribute.rs @@ -1,9 +1,9 @@ #![allow(clippy::type_complexity)] use indexmap::IndexMap; - -use crate::vdom::AttributeValue; use derive_where::derive_where; +use crate::vdom::AttributeValue; + /// The type of the Namspace pub type Namespace = &'static str; diff --git a/crates/sauron-core/src/html/attributes/attribute_value.rs b/crates/sauron-core/src/vdom/node/attribute_value.rs similarity index 100% rename from crates/sauron-core/src/html/attributes/attribute_value.rs rename to crates/sauron-core/src/vdom/node/attribute_value.rs