aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-10-26 14:27:10 +0000
committerMatthew Wild <mwild1@gmail.com>2008-10-26 14:27:10 +0000
commitcd77265014a1ec51773c5cba92acb10670c829c0 (patch)
tree95ea2f8272e11ed52ce096fa1795697237885344
parent6db0c3f0824e87a0ba4ee47479bdae8aae8f90a3 (diff)
downloadprosody-cd77265014a1ec51773c5cba92acb10670c829c0.tar.gz
prosody-cd77265014a1ec51773c5cba92acb10670c829c0.zip
Make add_child() behave as expected. Old add_child() is now add_direct_child()
-rw-r--r--util/stanza.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index 95a19fbd..bbd4776d 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -29,13 +29,13 @@ function stanza_mt:query(xmlns)
end
function stanza_mt:tag(name, attrs)
local s = stanza(name, attrs);
- (self.last_add[#self.last_add] or self):add_child(s);
+ (self.last_add[#self.last_add] or self):add_direct_child(s);
t_insert(self.last_add, s);
return self;
end
function stanza_mt:text(text)
- (self.last_add[#self.last_add] or self):add_child(text);
+ (self.last_add[#self.last_add] or self):add_direct_child(text);
return self;
end
@@ -44,13 +44,19 @@ function stanza_mt:up()
return self;
end
-function stanza_mt:add_child(child)
+function stanza_mt:add_direct_child(child)
if type(child) == "table" then
t_insert(self.tags, child);
end
t_insert(self, child);
end
+function stanza_mt:add_child(child)
+ (self.last_add[#self.last_add] or self):add_direct_child(child);
+ t_insert(self.last_add, s);
+ return self;
+end
+
function stanza_mt:child_with_name(name)
for _, child in ipairs(self) do
if child.name == name then return child; end
@@ -101,7 +107,7 @@ function stanza_mt.__tostring(t)
end
function stanza_mt.__add(s1, s2)
- return s1:add_child(s2);
+ return s1:add_direct_child(s2);
end