attr: fix concat of class attrs on union
This commit is contained in:
parent
3e4bb127c7
commit
109e030c71
2 changed files with 32 additions and 1 deletions
|
@ -145,7 +145,7 @@ impl<'s> Attributes<'s> {
|
|||
if let Some(attrs0) = &mut self.0 {
|
||||
if let Some(mut attrs1) = other.0 {
|
||||
for (key, val) in attrs1.drain(..) {
|
||||
if !attrs0.iter().any(|(k, _)| *k == key) {
|
||||
if key == "class" || !attrs0.iter().any(|(k, _)| *k == key) {
|
||||
attrs0.push((key, val));
|
||||
}
|
||||
}
|
||||
|
|
31
src/lib.rs
31
src/lib.rs
|
@ -1776,6 +1776,37 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn link_reference_attrs_class() {
|
||||
test_parse!(
|
||||
concat!(
|
||||
"[text][tag]{.link}\n",
|
||||
"\n",
|
||||
"{.def}\n",
|
||||
"[tag]: url\n",
|
||||
"para\n",
|
||||
),
|
||||
Start(Paragraph, Attributes::new()),
|
||||
Start(
|
||||
Link("url".into(), LinkType::Span(SpanLinkType::Reference)),
|
||||
[("class", "link"), ("class", "def")].into_iter().collect(),
|
||||
),
|
||||
Str("text".into()),
|
||||
End(Link("url".into(), LinkType::Span(SpanLinkType::Reference))),
|
||||
End(Paragraph),
|
||||
Blankline,
|
||||
Start(
|
||||
LinkDefinition { label: "tag" },
|
||||
[("class", "def")].into_iter().collect()
|
||||
),
|
||||
Str("url".into()),
|
||||
End(LinkDefinition { label: "tag" }),
|
||||
Start(Paragraph, Attributes::new()),
|
||||
Str("para".into()),
|
||||
End(Paragraph),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn autolink() {
|
||||
test_parse!(
|
||||
|
|
Loading…
Reference in a new issue