diff --git a/minidom/src/element.rs b/minidom/src/element.rs index b01adcca..6366fa2c 100644 --- a/minidom/src/element.rs +++ b/minidom/src/element.rs @@ -146,6 +146,9 @@ impl PartialEq for Element { fn eq(&self, other: &Self) -> bool { if self.name() == other.name() && self.ns() == other.ns() && self.attrs().eq(other.attrs()) { + if self.nodes().count() != other.nodes().count() { + return false; + } self.nodes() .zip(other.nodes()) .all(|(node1, node2)| node1 == node2) @@ -978,6 +981,16 @@ mod tests { assert_eq!(elem, elem4); } + #[test] + fn test_compare_empty_children() { + let elem1 = Element::bare("p", ""); + let elem2 = Element::builder("p", "") + .append(Node::Element(Element::bare("span", ""))) + .build(); + + assert_ne!(elem1, elem2); + } + #[test] fn test_from_reader_with_prefixes() { let xml = b"";