Skip to content

Commit

Permalink
cleaning fix: safer element removal
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar committed Oct 4, 2024
1 parent ec51dc1 commit 2735620
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions htmldate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,9 @@ def load_html(htmlobject: Union[bytes, str, HtmlElement]) -> Optional[HtmlElemen
def clean_html(tree: HtmlElement, elemlist: List[str]) -> HtmlElement:
"Delete selected elements."
for element in tree.iter(elemlist): # type: ignore[call-overload]
try:
element.drop_tree()
except AttributeError: # pragma: no cover
element.getparent().remove(element)
parent = element.getparent()
if parent is not None:
parent.remove(element)
return tree


Expand Down

0 comments on commit 2735620

Please sign in to comment.