Software /
code /
prosody
Comparison
util/stanza.lua @ 8640:8f13ec2ceb06
util.stanza: Allow :text(nil) and :text("") as harmless nops
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 21 Mar 2018 22:04:20 +0000 |
parent | 8626:20532f191f8d |
child | 8645:06c73b010488 |
comparison
equal
deleted
inserted
replaced
8639:070a77c15f63 | 8640:8f13ec2ceb06 |
---|---|
109 t_insert(last_add, s); | 109 t_insert(last_add, s); |
110 return self; | 110 return self; |
111 end | 111 end |
112 | 112 |
113 function stanza_mt:text(text) | 113 function stanza_mt:text(text) |
114 check_text(text, "text"); | 114 if text ~= nil and text ~= "" then |
115 local last_add = self.last_add; | 115 check_text(text, "text"); |
116 (last_add and last_add[#last_add] or self):add_direct_child(text); | 116 local last_add = self.last_add; |
117 (last_add and last_add[#last_add] or self):add_direct_child(text); | |
118 end | |
117 return self; | 119 return self; |
118 end | 120 end |
119 | 121 |
120 function stanza_mt:up() | 122 function stanza_mt:up() |
121 local last_add = self.last_add; | 123 local last_add = self.last_add; |