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

Fixed bug with slot props variables #3122

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/compile/render_dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ export default function dom(
const reactive_stores = component.vars.filter(variable => variable.name[0] === '$' && variable.name[1] !== '$');

if (component.slots.size > 0) {
component.vars.map(v => {
if (v.hoistable) filtered_declarations.push(v.name);
});
filtered_declarations.push('$$slots', '$$scope');
}

Expand Down
7 changes: 7 additions & 0 deletions test/runtime/samples/component-slot-let-e/Nested.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
let fooText = 'foo';
</script>

<div>
<slot someText={fooText}></slot>
</div>
20 changes: 20 additions & 0 deletions test/runtime/samples/component-slot-let-e/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
html: `
<div>
<p>foo</p>
</div>
`,

async test({ assert, target, window }) {
const div = target.querySelector('div');
const click = new window.MouseEvent('click');

await div.dispatchEvent(click);

assert.htmlEqual(target.innerHTML, `
<div>
<p>foo</p>
</div>
`);
}
};
7 changes: 7 additions & 0 deletions test/runtime/samples/component-slot-let-e/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import Nested from './Nested.svelte';
</script>

<Nested let:someText={someText}>
<p>{someText}</p>
</Nested>