-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Do not recycle lastElementChild in display #1780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've removed the needs-triage label because we've been discussing this in Discord for a while so that @leriomaggio provided dozen variant of the issue and all of those variants were solved by cleaning up upfront when |
If i had to guess... I would say that the fact that we're creating a pyscript/pyscriptjs/src/pyscript.py Lines 111 to 129 in 5d49c20
As such, I think it would be fair to say that |
To whom it might concern, the current MR simply takes the easy approach by cleaning up the whole thing before applying any logic. This should guarantee no breaking changes whatsoever, but I do believe the current To track my thoughts:
def _write(element, value, append=False):
html, mime_type = _format_mime(value)
if html == "\\n":
return
if not append:
element.replaceChildren()
fragment = document.createRange().createContextualFragment(html)
element.append(fragment) that's it. |
Uh oh!
There was an error while loading. Please reload this page.
Checklist
What happened?
Instead of cleaning up the target container when
append=False
is used, we use thelastElementChild
assuming that's thediv
we eventually previously created on empty containers.The issues I see with this approach (this is PyScript classic too IIRC):
<py-script>
is a target, it's already a visual containerdiv
to append anything, but then all integration tests expect that so there must be a reason - amend probably not<script type="py">
is used, itstarget
is already a visual container ... so that previous questions applyappend=False
, we should reuse any previous content, as the new content goal is to replace it, whatever it waslastElementChild
to then branch out logic when append meanselement.append(new_content)
is also not super clear or useful, neither with new empty nodes, nor with already populated onesdiv
as content at all (<picture>
and<video>
IIRC and to name a few)Accordingly, we should (imho) improve the
display
append
attribute story, as right now it's rather causing issues instead and weird edge cases, failing expectations.What browsers are you seeing the problem on? (if applicable)
No response
Console info
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: