Skip to content

Commit

Permalink
fix slot fallback update parent (sveltejs#4598)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau authored and taylorzane committed Dec 17, 2020
1 parent 809d825 commit 135222b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Try using `globalThis` rather than `globals` for the benefit of non-Node servers and web workers ([#3561](https://github.com/sveltejs/svelte/issues/3561), [#4545](https://github.com/sveltejs/svelte/issues/4545))
* Support `{#await ... catch ...}` syntax shorthand ([#3623](https://github.com/sveltejs/svelte/issues/3623))
* Fix attaching of JS debugging comments to HTML comments ([#4565](https://github.com/sveltejs/svelte/issues/4565))
* Fix `<svelte:component/>` within `<slot/>` ([#4597](https://github.com/sveltejs/svelte/issues/4597))
* Fix issues with `<input type="number">` updates ([#4631](https://github.com/sveltejs/svelte/issues/4631), [#4687](https://github.com/sveltejs/svelte/issues/4687))
* Prevent illegal attribute names ([#4648](https://github.com/sveltejs/svelte/issues/4648))
* Fix `{#if}` block directly within `<slot/>` ([#4703](https://github.com/sveltejs/svelte/issues/4703))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Icon A
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Icon B
13 changes: 13 additions & 0 deletions test/runtime/samples/component-slot-fallback-5/Inner.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script>
import IconA from './IconA.svelte';
import IconB from './IconB.svelte';
let variable = false;
</script>

<button on:click={() => variable = !variable}>Click Me</button>
<div>
<slot>
<svelte:component this={variable ? IconA : IconB} />
</slot>
</div>
31 changes: 31 additions & 0 deletions test/runtime/samples/component-slot-fallback-5/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default {
html: `
<button>Click Me</button>
<div>Icon B</div>
`,

async test({ assert, target, window }) {
const btn = target.querySelector("button");
const clickEvent = new window.MouseEvent("click");

await btn.dispatchEvent(clickEvent);

assert.htmlEqual(
target.innerHTML,
`
<button>Click Me</button>
<div>Icon A</div>
`
);

await btn.dispatchEvent(clickEvent);

assert.htmlEqual(
target.innerHTML,
`
<button>Click Me</button>
<div>Icon B</div>
`
);
}
};
5 changes: 5 additions & 0 deletions test/runtime/samples/component-slot-fallback-5/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import Inner from "./Inner.svelte";
</script>

<Inner></Inner>

0 comments on commit 135222b

Please sign in to comment.