Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanceras committed Mar 28, 2024
1 parent 07ba03f commit 28dc42b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions crates/core/src/dom/dom_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use crate::{
vdom::{Attribute, Leaf},
};
use indexmap::IndexMap;
use std::borrow::Cow;
use std::cell::Ref;
use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use wasm_bindgen::{closure::Closure, JsCast, JsValue};
use web_sys::{self, Element, Node};
use std::borrow::Cow;

pub(crate) type EventClosure = Closure<dyn FnMut(web_sys::Event)>;
pub type NamedEventClosures = IndexMap<&'static str, EventClosure>;
Expand Down Expand Up @@ -86,10 +86,7 @@ impl fmt::Debug for DomInner {
.debug_tuple("Text")
.field(&text_node.borrow().whole_text().expect("whole text"))
.finish(),
Self::Symbol(symbol) => f
.debug_tuple("Symbol")
.field(&symbol.borrow())
.finish(),
Self::Symbol(symbol) => f.debug_tuple("Symbol").field(&symbol.borrow()).finish(),
Self::Comment(_) => write!(f, "Comment"),
Self::Fragment { .. } => write!(f, "Fragment"),
Self::StatefulComponent(_) => write!(f, "StatefulComponent"),
Expand Down Expand Up @@ -159,8 +156,8 @@ impl DomNode {
}

/// return the string content of this symbol
pub fn as_symbol(&self) -> Option<String>{
match &self.inner{
pub fn as_symbol(&self) -> Option<String> {
match &self.inner {
DomInner::Symbol(symbol) => Some(symbol.borrow().as_ref().to_string()),
_ => None,
}
Expand All @@ -186,11 +183,12 @@ impl DomNode {
} => {
let for_append = for_append.into_iter();
for child in for_append {
if let Some(symbol) = child.as_symbol(){
if let Some(symbol) = child.as_symbol() {
//TODO: escape the `<` and `>`
element.insert_adjacent_html(intern("beforeend"), &symbol)
element
.insert_adjacent_html(intern("beforeend"), &symbol)
.expect("must not error");
}else{
} else {
element
.append_child(&child.as_node())
.expect("append child");
Expand Down Expand Up @@ -590,7 +588,7 @@ where
inner: DomInner::Text(RefCell::new(document().create_text_node(txt))),
parent: Rc::new(RefCell::new(parent_node)),
},
Leaf::Symbol(symbol) => DomNode{
Leaf::Symbol(symbol) => DomNode {
inner: DomInner::Symbol(Rc::new(RefCell::new(symbol.clone()))),
parent: Rc::new(RefCell::new(parent_node)),
},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/vdom/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::borrow::Cow;
pub enum Leaf<MSG> {
/// Text variant of a virtual node
Text(Cow<'static, str>),
/// Html entities such as &nbsp; &gt;
/// Html entities such as &nbsp; &gt;
Symbol(Cow<'static, str>),
/// A comment node
Comment(Cow<'static, str>),
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/vdom/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl<MSG> Node<MSG> {
}

/// return the html entity if it is a symbol variant
pub fn as_symbol(&self) -> Option<&str>{
match self{
pub fn as_symbol(&self) -> Option<&str> {
match self {
Self::Leaf(Leaf::Symbol(symbol)) => Some(symbol),
_ => None,
}
Expand Down

0 comments on commit 28dc42b

Please sign in to comment.