From c1956316d179239217abcadc3e9bdaa055607531 Mon Sep 17 00:00:00 2001 From: manatlan Date: Thu, 14 Mar 2024 08:17:34 +0100 Subject: [PATCH] use clear(x) in place of set(x) --- htag/tag.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htag/tag.py b/htag/tag.py index 6792b86..a2e2fb1 100644 --- a/htag/tag.py +++ b/htag/tag.py @@ -352,17 +352,20 @@ async def update(self) -> bool: logger.error("This component is not tied in a hrenderer") return False - def clear(self): - """ remove all childs """ + def clear(self,elt:AnyTags=None): + """ remove all childs and replace content if provided """ for t in self._childs: # remove parenting if isinstance(t,Tag): t.remove() self._childs=Elements() + if elt is not None: + self.add( elt) + # DEPRECATED def set(self,elt:AnyTags): """ a bit like .innerHTML setting (avoid clear+add)""" - self.clear() - self.add( elt) + print("***DEPRECATED***, use .clear(x) in place of .set(x) !") + self.clear(elt) def remove(self, elt=None): """Remove an object(elt) from its childs, or itself (if none), if attached (has parent)"""