Comparison

util/stanza.lua @ 8999:a2a4c225a3f8

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 08 Jul 2018 19:12:17 +0200
parent 8894:7273fb6af831
parent 8998:6bddc90eeb27
child 9217:7df29c5fbb9b
comparison
equal deleted inserted replaced
8997:8c4dd4375823 8999:a2a4c225a3f8
147 local last_add = self.last_add; 147 local last_add = self.last_add;
148 (last_add and last_add[#last_add] or self):add_direct_child(child); 148 (last_add and last_add[#last_add] or self):add_direct_child(child);
149 return self; 149 return self;
150 end 150 end
151 151
152 function stanza_mt:remove_children(name, xmlns)
153 xmlns = xmlns or self.attr.xmlns;
154 return self:maptags(function (tag)
155 if (not name or tag.name == name) and tag.attr.xmlns == xmlns then
156 return nil;
157 end
158 return tag;
159 end);
160 end
161
152 function stanza_mt:get_child(name, xmlns) 162 function stanza_mt:get_child(name, xmlns)
153 for _, child in ipairs(self.tags) do 163 for _, child in ipairs(self.tags) do
154 if (not name or child.name == name) 164 if (not name or child.name == name)
155 and ((not xmlns and self.attr.xmlns == child.attr.xmlns) 165 and ((not xmlns and self.attr.xmlns == child.attr.xmlns)
156 or child.attr.xmlns == xmlns) then 166 or child.attr.xmlns == xmlns) then