mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
minidom: clarify meaning of Element.name (being the local name)
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
171e7f1f34
commit
40b92d64e2
1 changed files with 13 additions and 2 deletions
|
@ -207,8 +207,7 @@ impl Element {
|
|||
)
|
||||
}
|
||||
|
||||
/// Returns a reference to the name of this element.
|
||||
// TODO: rename local_name
|
||||
/// Returns a reference to the local name of this element (that is, without a possible prefix).
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
@ -1079,6 +1078,18 @@ mod tests {
|
|||
assert_eq!(elem.unwrap(), elem2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_reader_split_prefix() {
|
||||
let xml = "<foo:bar xmlns:foo='ns1'/>";
|
||||
let mut reader = EventReader::from_str(xml);
|
||||
let elem = Element::from_reader(&mut reader).unwrap();
|
||||
|
||||
assert_eq!(elem.name(), String::from("bar"));
|
||||
assert_eq!(elem.ns(), String::from("ns1"));
|
||||
// Ensure the prefix is properly added to the store
|
||||
assert_eq!(elem.prefixes.get(&String::from("ns1")), Some(Some(String::from("foo"))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_spectest_xml() {
|
||||
// From: https://gitlab.com/lumi/minidom-rs/issues/8
|
||||
|
|
Loading…
Reference in a new issue