Diff

util/stanza.lua @ 4936:92c86e11fd44

util.stanza: Make stanza:childtags() behave like :get_child()
author Kim Alvefur <zash@zash.se>
date Thu, 05 Jul 2012 17:58:47 +0200
parent 4749:b9de59ea8dad
child 5090:61c7c53c06d5
line wrap: on
line diff
--- 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