Skip to content
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

More robust handling of {@html ...} #3329

Merged
merged 5 commits into from
Aug 4, 2019
Merged

More robust handling of {@html ...} #3329

merged 5 commits into from
Aug 4, 2019

Conversation

Rich-Harris
Copy link
Member

Started working on this but just going to leave a failing test here for now. Basically, too much is happening during mount — when something is remounted (i.e. after a list shuffle) new DOM is created. We probably need an abstraction for handling fragments generated from HTML.

@Rich-Harris Rich-Harris changed the title failing test for #3285 More robust handling of {@html ...} Aug 3, 2019
@Rich-Harris
Copy link
Member Author

Significantly simplifies the code for {@html ...} tags by adding an HtmlTag class that does the heavy lifting. This class keeps track of the nodes it generates, so that it can efficiently detach them without needing to surround the tag with anchors. In the occasional situations where an anchor is necessary (because the following item isn't a DOM node), we can now use an empty string instead of ugly <noscript> elements, since it no longer uses the insertAdjacentHTML API.

Where possible (e.g. <div>{@html stuff}</div>), it will continue to use the innerHTML optimisation.

I haven't checked yet, but I'm optimistic that it will also fix #3326.

@Rich-Harris
Copy link
Member Author

Confirmed this fixes #3326 — added a test

@sanderhahn
Copy link
Contributor

Maybe these changes also fix #2711?

@Conduitry
Copy link
Member

Oh nice, yeah it looks like it fixes that as well.

@Conduitry
Copy link
Member

Actually, the REPLs in the first and third comments in the issue seem fixed with this PR. The second REPL still has something weird going on.

@Rich-Harris Rich-Harris merged commit 873a561 into master Aug 4, 2019
@Rich-Harris Rich-Harris deleted the gh-3285 branch August 4, 2019 13:24
@Rich-Harris
Copy link
Member Author

nice, another one down. The remaining bug in #2711 that wasn't fixed by this PR is fixed in #3350

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.

3 participants