Skip to content

Fix #2150 - Avoid trashing previous added elements #2151

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

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

WebReflection
Copy link
Contributor

Description

This MR fixes #2150 by using element.insertAdjacentHTML so that previously appended elements don't lose their reference.

Changes

  • use appendChild instead of append for elements, as append is slower due checks on arguments type and it brings no benefits there
  • use insertAdjacentHTML instead of innerHTML += '...' as latter would replace all previously appended children each time it's used

Question

@mchilvers what's the intent there? append already works with text but here it looks like we wanted to accept HTML and not just text, if this is correct then this MR should improve a lot the current state, thanks.

Checklist

  • All tests pass locally
  • I have updated CHANGELOG.md
  • I have created documentation for this(if applicable)

@WebReflection
Copy link
Contributor Author

FYI I am trying to figure out if this was covered, just to be sure I am using/reaching the right primitive there ... if that's confirmed, I think we should be good to merge this /cc @mchilvers

@WebReflection WebReflection requested a review from ntoll September 3, 2024 08:03
@WebReflection
Copy link
Contributor Author

@ntoll by any chance you can confirm this is good to go? it'd be great to have for our next release, thanks!

@WebReflection WebReflection merged commit eb31e51 into pyscript:main Sep 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants