fixup! block attributes

This commit is contained in:
Noah Hellman 2023-01-15 20:03:22 +01:00
parent b937b4f71e
commit eb6b58f2a9

View file

@ -59,10 +59,27 @@ impl<'s> Attributes<'s> {
}; };
let attrs = self.0.as_mut().unwrap(); let attrs = self.0.as_mut().unwrap();
if let Some(i) = attrs.iter().position(|(a, _)| *a == attr) {
let prev = &mut attrs[i].1;
if attr == "class" {
*prev = format!("{} {}", prev, val).into();
} else {
*prev = val;
}
} else {
attrs.push((attr, val)); attrs.push((attr, val));
} }
}
#[must_use]
pub fn is_empty(&self) -> bool {
if let Some(v) = &self.0 {
v.is_empty()
} else {
true
}
}
#[cfg(test)]
pub fn iter(&self) -> impl Iterator<Item = (&'s str, &str)> + '_ { pub fn iter(&self) -> impl Iterator<Item = (&'s str, &str)> + '_ {
self.0 self.0
.iter() .iter()