-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Call onMount when connected & clean up when disconnected for custom element #4522
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
antony
merged 21 commits into
sveltejs:master
from
hontas:feature/custom-element-destroy
Feb 15, 2021
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f2eb632
pseudo code
hontas 6ebffd2
pseudo code
hontas 7d9ff14
Merge branch 'master' of https://github.com/sveltejs/svelte
hontas 0245239
cleanup
hontas 72acf15
Merge remote-tracking branch 'upstream/master'
55559e6
Merge remote-tracking branch 'upstream/master'
b1fc702
Merge remote-tracking branch 'upstream/master'
hontas 4730331
Merge branch 'master' of github.com:hontas/svelte
hontas 297dfcc
Merge remote-tracking branch 'upstream/master'
hontas 527c14d
Merge remote-tracking branch 'upstream/master'
hontas 421f2cf
Merge branch 'master' of https://github.com/sveltejs/svelte
hontas 9e78f39
get console output from puppeteer
hontas 18334b4
custom element call onDestroy when disconnected
hontas a493b57
only call onDestroy callbacks
hontas 7d9636f
lifecycle hooks and custom elements
95ad63f
simplify logic, trigger tests
90f5c0a
fix whitespace, trigger tests
628f80e
do not reset on_mount so that it can fire again if reinserted
hontas 971ca91
simplify isCustomElement check
hontas 9cc7dd2
remove whitespace
hontas 1451a88
simpler isCustomElement & skip extra function call
hontas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<svelte:options tag="my-app"/> | ||
|
||
<script> | ||
import { onMount, onDestroy } from 'svelte'; | ||
|
||
let el; | ||
let parentEl; | ||
|
||
onMount(() => { | ||
parentEl = el.parentNode.host.parentElement; | ||
|
||
return () => { | ||
parentEl.dataset.onMountDestroyed = true; | ||
} | ||
}); | ||
|
||
onDestroy(() => { | ||
parentEl.dataset.destroyed = true; | ||
}) | ||
</script> | ||
|
||
<div bind:this={el}></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as assert from 'assert'; | ||
import './main.svelte'; | ||
|
||
export default function (target) { | ||
target.innerHTML = '<my-app/>'; | ||
const el = target.querySelector('my-app'); | ||
target.removeChild(el); | ||
|
||
assert.ok(target.dataset.onMountDestroyed); | ||
assert.equal(target.dataset.destroyed, undefined); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.