fix: viewBox translation by not accidentally stringifying literals (#3527)

* fix: don't double stringify lits

* also split off namespaces in translation
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-01-08 16:12:48 -08:00
1 parent a3812d66da
commit 343c48f5ad
4 files changed
+109 -3

No files matched your search

+9
View File
@@ -57,6 +57,10 @@ pub fn rsx_node_from_html(node: &Node) -> Option<BodyNode> {
.attributes
.iter()
.map(|(name, value)| {
// xlink attributes are deprecated and technically we can't handle them.
// todo(jon): apply the namespaces to the attributes
let (_namespace, name) = name.split_once(':').unwrap_or(("", name));
let value = HotLiteral::from_raw_text(value.as_deref().unwrap_or("false"));
let attr = if let Some(name) = map_html_attribute_to_rsx(name) {
let name = if let Some(name) = name.strip_prefix("r#") {
@@ -89,6 +93,11 @@ pub fn rsx_node_from_html(node: &Node) -> Option<BodyNode> {
));
}
// the html-parser crate we use uses a HashMap for attributes. This leads to a
// non-deterministic order of attributes.
// Sort them here
attributes.sort_by(|a, b| a.name.to_string().cmp(&b.name.to_string()));
let children = el.children.iter().filter_map(rsx_node_from_html).collect();
Some(BodyNode::Element(Element {