move implementatipn

This commit is contained in:
Sara Vieira 2022-12-22 15:02:41 +00:00
parent ae1462cdb8
commit da3e87a38e
2 changed files with 5 additions and 2 deletions

View File

@ -357,7 +357,7 @@ impl Declare {
write!(f, "<{}", #name)?;
#print_attrs
for (key, value) in &self.data_attributes {
write!(f, " data-{}=\"{}\"", str::replace(key, "_", "-"),
write!(f, " data-{}=\"{}\"", key,
crate::escape_html_attribute(value.to_string()))?;
}
for (key, value) in &self.aria_attributes {

View File

@ -76,7 +76,10 @@ fn extract_data_attrs(attrs: &mut StringyMap<Ident, TokenTree>) -> StringyMap<St
let key_name = key.to_string();
if let Some(key_name) = key_name.strip_prefix("data_") {
let value = attrs.remove(&key).unwrap();
data.insert(key_name.to_string(), value);
// makes sure if a data attribute has more than one hyphen
// they all get transformed
let key = str::replace(key_name, "_", "-");
data.insert(key.to_string(), value);
}
}
data