From c1e6b9426632394045549a99cac18b11955bb687 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 9 Jan 2009 17:27:53 +0000 Subject: Restore fix for missing last_add on deserialized stanzas. Thanks to tsing for discovering. --- util/stanza.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/stanza.lua') diff --git a/util/stanza.lua b/util/stanza.lua index 6af7e2b2..c4cecb6f 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -199,6 +199,9 @@ function deserialize(stanza) end end stanza.tags = tags; + if not stanza.last_add then + stanza.last_add = {}; + end end end -- cgit v1.2.3 From 937375dda1377019b4f592b6f9cea9103cdbd967 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 11 Jan 2009 06:27:57 +0000 Subject: Add child_with_ns() method to stanza elements, and fix child_with_name() to iterate tags rather than all children --- util/stanza.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'util/stanza.lua') diff --git a/util/stanza.lua b/util/stanza.lua index c4cecb6f..14a8f395 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -87,11 +87,17 @@ function stanza_mt:add_child(child) end function stanza_mt:child_with_name(name) - for _, child in ipairs(self) do + for _, child in ipairs(self.tags) do if child.name == name then return child; end end end +function stanza_mt:child_with_ns(ns) + for _, child in ipairs(self.tags) do + if child.attr.xmlns == ns then return child; end + end +end + function stanza_mt:children() local i = 0; return function (a) -- cgit v1.2.3