From ecf76dfbc72292545b01edf0bdf8ca5d763c88be Mon Sep 17 00:00:00 2001 From: Schell Carl Scivally Date: Fri, 8 Nov 2024 15:10:54 +1300 Subject: [PATCH] don't do replacements --- crates/mogwai-dom/src/view/js.rs | 7 +++---- crates/mogwai-dom/src/view/ssr.rs | 15 +++------------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/crates/mogwai-dom/src/view/js.rs b/crates/mogwai-dom/src/view/js.rs index 287f245..be92606 100644 --- a/crates/mogwai-dom/src/view/js.rs +++ b/crates/mogwai-dom/src/view/js.rs @@ -1,11 +1,12 @@ //! Wrapper around Javascript DOM nodes. use std::{ + borrow::Cow, collections::HashMap, future::Future, ops::{Bound, Deref, RangeBounds}, pin::Pin, sync::{Arc, Weak}, - task::Waker, borrow::Cow, + task::Waker, }; use anyhow::Context; @@ -604,9 +605,7 @@ pub(crate) fn build( }); let key = match identity { ViewIdentity::Branch(t) => HydrationKey::try_new(t, attribs, may_parent), - ViewIdentity::NamespacedBranch(t, _) => { - HydrationKey::try_new(t, attribs, may_parent) - } + ViewIdentity::NamespacedBranch(t, _) => HydrationKey::try_new(t, attribs, may_parent), ViewIdentity::Leaf(t) => HydrationKey::try_new(t, attribs, may_parent), }?; key.hydrate()? diff --git a/crates/mogwai-dom/src/view/ssr.rs b/crates/mogwai-dom/src/view/ssr.rs index 2319136..496e908 100644 --- a/crates/mogwai-dom/src/view/ssr.rs +++ b/crates/mogwai-dom/src/view/ssr.rs @@ -2,7 +2,7 @@ use anyhow::Context; use async_executor::Executor; use async_lock::RwLock; -use std::{collections::HashMap, future::Future, ops::DerefMut, pin::Pin, sync::Arc, borrow::Cow}; +use std::{borrow::Cow, collections::HashMap, future::Future, ops::DerefMut, pin::Pin, sync::Arc}; use mogwai::{ either::Either, @@ -220,12 +220,7 @@ impl SsrDom { pub fn text(executor: Arc>, s: &str) -> Self { SsrDom { executor, - node: Arc::new(RwLock::new(SsrNode::Text( - s.replace("&", "&") - .replace("<", "<") - .replace(">", ">") - .into(), - ))), + node: Arc::new(RwLock::new(SsrNode::Text(s.into()))), events: Default::default(), } } @@ -250,11 +245,7 @@ impl SsrDom { pub fn set_text(&self, text: &str) -> anyhow::Result<()> { let mut lock = self.node.try_write().context("can't lock for writing")?; if let SsrNode::Text(prev) = lock.deref_mut() { - *prev = text - .replace("&", "&") - .replace("<", "<") - .replace(">", ">") - .to_string(); + *prev = text.to_string(); } else { anyhow::bail!("not a text node"); }