Skip to content

Commit

Permalink
use clear(x) in place of set(x)
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Mar 14, 2024
1 parent 90f2c32 commit c195631
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions htag/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"""
Expand Down

0 comments on commit c195631

Please sign in to comment.