Skip to content

Commit

Permalink
refactor: move AttributeValue to vdom
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanceras committed Mar 5, 2024
1 parent d0ccc9d commit 5c0b250
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions crates/html-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rphtml::types::BoxDynError;
use sauron_core::{
html::{attributes::*, lookup, *},
vdom::Node,
vdom::AttributeValue,
};
use std::fmt;
use std::io;
Expand Down
4 changes: 2 additions & 2 deletions crates/sauron-core/src/dom/dom_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions crates/sauron-core/src/dom/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions crates/sauron-core/src/html/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
//! [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;
pub use value::Value;

#[macro_use]
mod attribute_macros;
mod attribute_value;
mod listener;
mod special;
mod style;
Expand Down
6 changes: 4 additions & 2 deletions crates/sauron-core/src/html/attributes/attribute_macros.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/sauron-core/src/svg/attributes.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
4 changes: 2 additions & 2 deletions crates/sauron-core/src/vdom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};

Expand Down
3 changes: 1 addition & 2 deletions crates/sauron-core/src/vdom/map_msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{
html::attributes::AttributeValue,
vdom::{Attribute, Element, Listener, Node},
vdom::{Attribute, Element, Listener, Node, AttributeValue},
};


Expand Down
9 changes: 6 additions & 3 deletions crates/sauron-core/src/vdom/node.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/sauron-core/src/vdom/node/attribute.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 5c0b250

Please sign in to comment.