Skip to content

Commit

Permalink
don't do replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Nov 8, 2024
1 parent 1d9e0f4 commit ecf76df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
7 changes: 3 additions & 4 deletions crates/mogwai-dom/src/view/js.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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()?
Expand Down
15 changes: 3 additions & 12 deletions crates/mogwai-dom/src/view/ssr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -220,12 +220,7 @@ impl SsrDom {
pub fn text(executor: Arc<Executor<'static>>, s: &str) -> Self {
SsrDom {
executor,
node: Arc::new(RwLock::new(SsrNode::Text(
s.replace("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;")
.into(),
))),
node: Arc::new(RwLock::new(SsrNode::Text(s.into()))),
events: Default::default(),
}
}
Expand All @@ -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("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;")
.to_string();
*prev = text.to_string();
} else {
anyhow::bail!("not a text node");
}
Expand Down

0 comments on commit ecf76df

Please sign in to comment.