Skip to content

Svelte 5: contenteditable="true" with bind:innerText breaks the output of {@render children()} #11653

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

Closed
Serator opened this issue May 16, 2024 · 5 comments · Fixed by #12210
Closed
Assignees
Milestone

Comments

@Serator
Copy link

Serator commented May 16, 2024

Describe the bug

The same thing happens with bind:innerHTML / bind:textContent.

Reproduction

Logs

No response

System Info

-

Severity

annoyance

@dummdidumm
Copy link
Member

May be related to this breaking change in the sense of "children render comes in too late, binding has already taken over". Probably reasonable to look into changing this so that at least the initial value still comes in.

Would you expect updates to the content in the parent be reflected in the bound inner text in the child? Because that breaking change would change that.

@dummdidumm dummdidumm added this to the 5.0 milestone May 16, 2024
@Serator
Copy link
Author

Serator commented May 16, 2024

Would you expect updates to the content in the parent be reflected in the bound inner text in the child?

Yeah, but with contenteditable turned off (#11654).

@Serator
Copy link
Author

Serator commented Jun 29, 2024

@trueadm The output now works, but it is still incorrect (<!----> shouldn't be in the output):

image

You can check it out at the first link from the first post (Svelte 5 (runes) 🔴).

@Rich-Harris Rich-Harris reopened this Jun 29, 2024
@trueadm
Copy link
Contributor

trueadm commented Jun 30, 2024

This is a tricky one then. I viewed that as being fine. Svelte 5 has its own html output that differs from Svelte 4 and comments don’t affect layout.

That anchor is valid too as Svelte uses them for runtime updates. So it needs to be there in case your snippet updates.

We could strip it out of the innerHTML but that seems like a hack.

@Serator
Copy link
Author

Serator commented Jun 30, 2024

@trueadm Revisited my own examples and saw a typo. It looks like there is no bug and you have done everything correctly. I apologize for wasting your time.

image

There should be either bind:innerHTML={innerHTML} or bind:innerText={innerText} and the output of innerHTML along with the comment looks correct.

@Serator Serator closed this as completed Jun 30, 2024
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 a pull request may close this issue.

4 participants