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

don't detach <svelte:head> contents twice #3159

Closed
wants to merge 4 commits into from
Closed

Conversation

Rich-Harris
Copy link
Member

Fixes #2086. I'm slightly dubious about it — I think there might be cases where <head> children wouldn't be detached at all, with this change, so I'm leaving it as a draft for the moment. I think this is preferable to adding an if (node.parentNode) guard in the detach helper though.

@mrkishi
Copy link
Member

mrkishi commented Jul 3, 2019

Could this affect add_element as well?

if (parent_node) {
this.builders.mount.add_line(`@append(${parent_node}, ${name});`);
if (parent_node === '@_document.head' && !no_detach) this.builders.destroy.add_line(`@detach(${name});`);
} else {
this.builders.mount.add_line(`@insert(#target, ${name}, anchor);`);
if (!no_detach) this.builders.destroy.add_conditional('detaching', `@detach(${name});`);
}

@Rich-Harris
Copy link
Member Author

Found a better fix: #3172. This branch still has value for the additional test

@Rich-Harris Rich-Harris marked this pull request as ready for review July 4, 2019 00:23
@Rich-Harris
Copy link
Member Author

closing in favour of #3209

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.

Uncaught (in promise) TypeError: Cannot read property 'removeChild' of null
2 participants