util.stanza: Make stanza:childtags() behave like :get_child()
authorKim Alvefur <zash@zash.se>
Thu, 05 Jul 2012 17:58:47 +0200
changeset 4936 92c86e11fd44
parent 4935 bc62abceef07
child 4937 b3fe52353295
util.stanza: Make stanza:childtags() behave like :get_child()
util/stanza.lua
--- a/util/stanza.lua	Tue Jul 03 15:56:32 2012 +0200
+++ b/util/stanza.lua	Thu Jul 05 17:58:47 2012 +0200
@@ -133,14 +133,14 @@
 end
 
 function stanza_mt:childtags(name, xmlns)
-	xmlns = xmlns or self.attr.xmlns;
 	local tags = self.tags;
 	local start_i, max_i = 1, #tags;
 	return function ()
 		for i = start_i, max_i do
 			local v = tags[i];
 			if (not name or v.name == name)
-			and (not xmlns or xmlns == v.attr.xmlns) then
+			and ((not xmlns and self.attr.xmlns == v.attr.xmlns)
+				or v.attr.xmlns == xmlns) then
 				start_i = i+1;
 				return v;
 			end