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

[fix] const declared without let: binding get ignored #7434

Merged
merged 1 commit into from Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/compiler/compile/nodes/SlotTemplate.ts
Expand Up @@ -27,10 +27,7 @@ export default class SlotTemplate extends Node {

this.validate_slot_template_placement();

const has_let = info.attributes.some((node) => node.type === 'Let');
if (has_let) {
scope = scope.child();
}
scope = scope.child();

info.attributes.forEach((node) => {
switch (node.type) {
Expand Down
@@ -0,0 +1,2 @@
<slot name="box1" />
<slot />
15 changes: 15 additions & 0 deletions test/runtime/samples/const-tag-component-without-let/_config.js
@@ -0,0 +1,15 @@
export default {
html: `
<div>static dynamic</div>
<div>static dynamic</div>
<div>static dynamic</div>
`,
async test({ component, target, assert }) {
component.props = 'xxx';
assert.htmlEqual(target.innerHTML, `
<div>static xxx</div>
<div>static xxx</div>
<div>static xxx</div>
`);
}
};
24 changes: 24 additions & 0 deletions test/runtime/samples/const-tag-component-without-let/main.svelte
@@ -0,0 +1,24 @@
<script>
import Component from './Component.svelte';
export let props = "dynamic";
</script>

<Component>
<svelte:fragment slot="box1">
{@const foo = "static"}
{@const bar = props}
<div>{foo} {bar}</div>
</svelte:fragment>

<svelte:fragment>
{@const foo = "static"}
{@const bar = props}
<div>{foo} {bar}</div>
</svelte:fragment>
</Component>

<Component>
{@const foo = "static"}
{@const bar = props}
<div>{foo} {bar}</div>
</Component>