Changeset

8999:a2a4c225a3f8

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 08 Jul 2018 19:12:17 +0200
parents 8997:8c4dd4375823 (current diff) 8998:6bddc90eeb27 (diff)
children 9000:4d64ff0719a6
files util/stanza.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/stanza.lua	Sun Jul 08 04:17:54 2018 +0200
+++ b/util/stanza.lua	Sun Jul 08 19:12:17 2018 +0200
@@ -149,6 +149,16 @@
 	return self;
 end
 
+function stanza_mt:remove_children(name, xmlns)
+	xmlns = xmlns or self.attr.xmlns;
+	return self:maptags(function (tag)
+		if (not name or tag.name == name) and tag.attr.xmlns == xmlns then
+			return nil;
+		end
+		return tag;
+	end);
+end
+
 function stanza_mt:get_child(name, xmlns)
 	for _, child in ipairs(self.tags) do
 		if (not name or child.name == name)