-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[fix]destroy empty component #7492
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
tanhauhau
merged 13 commits into
sveltejs:master
from
magentaqin:bugfix/destroy-empty-component
Jul 4, 2022
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
007d952
fix: destroy non-fragment element such as empty components
35da0f5
fix: fragment property of Empty Component is set as true in dev mode,…
6406423
Merge branch 'sveltejs:master' into bugfix/destroy-empty-component
magentaqin e57a97b
chore: revert 'removal' of component.compile_options.dev
magentaqin 3d6cd65
feat: add test for destroying empty component
magentaqin ff1ada7
chore: update typechecking callback
magentaqin 09852ff
chore: revert fragment dev checks
magentaqin 81b9ba0
Merge branch 'sveltejs:master' into bugfix/destroy-empty-component
magentaqin 26d1853
chore: remove unnecessary comment
magentaqin 42b7683
chore: update test for empty-component-destroy
magentaqin 8b6ffce
Merge branch 'sveltejs:master' into bugfix/destroy-empty-component
magentaqin e285f44
fix: revert back the patching of console.log
magentaqin 21a01f5
use before_test and after_test
tanhauhau 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<script> | ||
import { onDestroy } from 'svelte'; | ||
|
||
onDestroy(() => { | ||
console.log('destroy'); | ||
}); | ||
</script> |
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,17 @@ | ||
export default { | ||
html: ` | ||
<button>destroy component</button> | ||
`, | ||
|
||
async test({ assert, target, window }) { | ||
const button = target.querySelector('button'); | ||
const event = new window.MouseEvent('click'); | ||
const messages = []; | ||
console.log = msg => messages.push(msg); | ||
await button.dispatchEvent(event); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<button>destroy component</button> | ||
`); | ||
assert.deepEqual(messages, ['destroy']); | ||
} | ||
}; |
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,8 @@ | ||
<script> | ||
import Empty from './Empty.svelte'; | ||
let active = true; | ||
</script> | ||
|
||
<button on:click='{() => active = false }'>destroy component</button> | ||
|
||
<svelte:component this={active ? Empty : null} /> |
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.