8000 Fix #1780 - Clean up elements before writing (#1781) · pyscript/pyscript@bc1cac9 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc1cac9

Browse files
Fix #1780 - Clean up elements before writing (#1781)
1 parent 50f7ab0 commit bc1cac9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pyscript.core/src/stdlib/pyscript/display.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io
44
import re
55

6-
from pyscript.magic_js import document, window, current_target
6+
from pyscript.magic_js import current_target, document, window
77

88
_MIME_METHODS = {
99
"__repr__": "text/plain",
@@ -154,8 +154,10 @@ def display(*values, target=None, append=True):
154154
# if element is a <script type="py">, it has a 'target' attribute which
155155
# points to the visual element holding the displayed values. In that case,
156156
# use that.
157-
if element.tagName == 'SCRIPT' and hasattr(element, 'target'):
157+
if element.tagName == "SCRIPT" and hasattr(element, "target"):
158158
element = element.target
159159

160160
for v in values:
161+
if not append:
162+
element.replaceChildren()
161163
_write(element, v, append=append)

0 commit comments

Comments
 (0)
0