fix const declared without let: binding get ignored (#7434)

pull/6583/head
Tan Li Hau 2 years ago committed by GitHub
parent 1e0c10bebc
commit e50be669cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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) {

@ -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>
`);
}
};

@ -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>
Loading…
Cancel
Save