mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
NamespaceSet::set_parent(): don't require a full Element
by passing just a reference to a NamespaceSet we could reuse this for xmlns elision in the serialization code.
This commit is contained in:
parent
98fd71fd3f
commit
7d2699e08e
1 changed files with 4 additions and 4 deletions
|
@ -136,9 +136,9 @@ impl NamespaceSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_parent(&self, parent: &Element) {
|
fn set_parent(&self, parent: Rc<NamespaceSet>) {
|
||||||
let mut parent_ns = self.parent.borrow_mut();
|
let mut parent_ns = self.parent.borrow_mut();
|
||||||
let new_set = parent.namespaces.clone();
|
let new_set = parent;
|
||||||
*parent_ns = Some(new_set);
|
*parent_ns = Some(new_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ impl Element {
|
||||||
/// assert_eq!(child.name(), "new");
|
/// assert_eq!(child.name(), "new");
|
||||||
/// ```
|
/// ```
|
||||||
pub fn append_child(&mut self, child: Element) -> &mut Element {
|
pub fn append_child(&mut self, child: Element) -> &mut Element {
|
||||||
child.namespaces.set_parent(&self);
|
child.namespaces.set_parent(self.namespaces.clone());
|
||||||
|
|
||||||
self.children.push(Node::Element(child));
|
self.children.push(Node::Element(child));
|
||||||
if let Node::Element(ref mut cld) = *self.children.last_mut().unwrap() {
|
if let Node::Element(ref mut cld) = *self.children.last_mut().unwrap() {
|
||||||
|
@ -882,7 +882,7 @@ impl ElementBuilder {
|
||||||
// Propagate namespaces
|
// Propagate namespaces
|
||||||
for node in &element.children {
|
for node in &element.children {
|
||||||
if let Node::Element(ref e) = *node {
|
if let Node::Element(ref e) = *node {
|
||||||
e.namespaces.set_parent(&element);
|
e.namespaces.set_parent(element.namespaces.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue