fixup! block attributes
This commit is contained in:
parent
b937b4f71e
commit
eb6b58f2a9
1 changed files with 19 additions and 2 deletions
19
src/attr.rs
19
src/attr.rs
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue