Implement scansion:any in attr

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-04-17 23:42:06 +02:00
parent f5ac2d7ec6
commit 1f0a7e4e18
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -227,6 +227,10 @@ impl<'a> PartialEq<&Element> for ScanElement<'a> {
};
for (attr, val) in self.elem.attrs() {
if val == "{scansion:any}" {
continue;
}
match (attr, other.attr(attr)) {
(attr, _) if attr == "scansion:strict" => continue,
(_, None) => return false,
@ -479,4 +483,14 @@ mod tests {
assert_ne!(scan1, &elem2);
}
#[test]
fn ignore_attr_val_success() {
let elem1: Element = "<message scansion:strict='true' xmlns='jabber:client' id='{scansion:any}' />"
.parse().unwrap();
let elem2: Element = "<message xmlns='jabber:client' id='some-id' />".parse().unwrap();
let scan1 = ScanElement::new(&elem1);
assert_eq!(scan1, &elem2);
}
}