Use the correct to-static impl for sending escaped strings via hotreload (#2753)
This commit is contained in:
1 parent
828cc502f1
commit
189772a17b
3 files changed
+16
-16
No files matched your search
@@ -408,4 +408,13 @@ mod tests {
|
|||||||
println!("{}", input.to_string_with_quotes());
|
println!("{}", input.to_string_with_quotes());
|
||||||
assert!(input.is_static());
|
assert!(input.is_static());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn to_static() {
|
||||||
|
let input = syn::parse2::<IfmtInput>(quote! { "body {{ background: red; }}" }).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
input.to_static(),
|
||||||
|
Some("body { background: red; }".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -156,14 +156,7 @@ impl BodyNode {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BodyNode::Text(text) if text.is_static() => {
|
BodyNode::Text(text) => text.to_template_node(),
|
||||||
let text = text.input.source.clone();
|
|
||||||
let text = intern(text.value().as_str());
|
|
||||||
TemplateNode::Text { text }
|
|
||||||
}
|
|
||||||
BodyNode::Text(text) => TemplateNode::Dynamic {
|
|
||||||
id: text.dyn_idx.get(),
|
|
||||||
},
|
|
||||||
BodyNode::RawExpr(exp) => TemplateNode::Dynamic {
|
BodyNode::RawExpr(exp) => TemplateNode::Dynamic {
|
||||||
id: exp.dyn_idx.get(),
|
id: exp.dyn_idx.get(),
|
||||||
},
|
},
|
||||||
@@ -209,7 +202,7 @@ impl BodyNode {
|
|||||||
match self {
|
match self {
|
||||||
BodyNode::Element(el) => el.name.span(),
|
BodyNode::Element(el) => el.name.span(),
|
||||||
BodyNode::Component(component) => component.name.span(),
|
BodyNode::Component(component) => component.name.span(),
|
||||||
BodyNode::Text(text) => text.input.source.span(),
|
BodyNode::Text(text) => text.input.span(),
|
||||||
BodyNode::RawExpr(exp) => exp.span(),
|
BodyNode::RawExpr(exp) => exp.span(),
|
||||||
BodyNode::ForLoop(fl) => fl.for_token.span(),
|
BodyNode::ForLoop(fl) => fl.for_token.span(),
|
||||||
BodyNode::IfChain(f) => f.if_token.span(),
|
BodyNode::IfChain(f) => f.if_token.span(),
|
||||||
|
|||||||
@@ -66,13 +66,11 @@ impl TextNode {
|
|||||||
#[cfg(feature = "hot_reload")]
|
#[cfg(feature = "hot_reload")]
|
||||||
pub fn to_template_node(&self) -> TemplateNode {
|
pub fn to_template_node(&self) -> TemplateNode {
|
||||||
use crate::intern;
|
use crate::intern;
|
||||||
match self.is_static() {
|
match self.input.to_static() {
|
||||||
true => {
|
Some(text) => TemplateNode::Text {
|
||||||
let text = self.input.source.clone();
|
text: intern(text.as_str()),
|
||||||
let text = intern(text.value().as_str());
|
},
|
||||||
TemplateNode::Text { text }
|
None => TemplateNode::Dynamic {
|
||||||
}
|
|
||||||
false => TemplateNode::Dynamic {
|
|
||||||
id: self.dyn_idx.get(),
|
id: self.dyn_idx.get(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user