Skip to content

Commit 3561be2

Browse files
committed
simplify
1 parent 39e2560 commit 3561be2

File tree

5 files changed

+3
-76
lines changed

5 files changed

+3
-76
lines changed

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { Identifier } from './visitors/Identifier.js';
2323
import { IfBlock } from './visitors/IfBlock.js';
2424
import { KeyBlock } from './visitors/KeyBlock.js';
2525
import { LabeledStatementLegacy } from './visitors/LabeledStatement.js';
26-
import { LetDirective } from './visitors/LetDirective.js';
2726
import { MemberExpressionRunes } from './visitors/MemberExpression.js';
2827
import { PropertyDefinitionRunes } from './visitors/PropertyDefinition.js';
2928
import { RegularElement } from './visitors/RegularElement.js';
@@ -79,7 +78,6 @@ const template_visitors = {
7978
HtmlTag,
8079
IfBlock,
8180
KeyBlock,
82-
LetDirective,
8381
RegularElement,
8482
RenderTag,
8583
SlotElement,

packages/svelte/src/compiler/phases/3-transform/server/visitors/LetDirective.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/svelte/src/compiler/phases/3-transform/server/visitors/SlotElement.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ export function SlotElement(node, context) {
1515
/** @type {Expression[]} */
1616
const spreads = [];
1717

18-
/** @type {ExpressionStatement[]} */
19-
const lets = [];
20-
2118
/** @type {Expression} */
2219
let expression = b.call('$.default_slot', b.id('$$props'));
2320

@@ -36,14 +33,9 @@ export function SlotElement(node, context) {
3633
props.push(b.init(attribute.name, value));
3734
}
3835
}
39-
} else if (attribute.type === 'LetDirective') {
40-
lets.push(/** @type {ExpressionStatement} */ (context.visit(attribute)));
4136
}
4237
}
4338

44-
// Let bindings first, they can be used on attributes
45-
context.state.init.push(...lets);
46-
4739
const props_expression =
4840
spreads.length === 0
4941
? b.object(props)
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import { BlockStatement, ExpressionStatement } from 'estree' */
1+
/** @import { BlockStatement } from 'estree' */
22
/** @import { SvelteFragment } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
44

@@ -7,20 +7,5 @@
77
* @param {ComponentContext} context
88
*/
99
export function SvelteFragment(node, context) {
10-
const child_state = {
11-
...context.state,
12-
getters: { ...context.state.getters }
13-
};
14-
15-
for (const attribute of node.attributes) {
16-
if (attribute.type === 'LetDirective') {
17-
context.state.template.push(
18-
/** @type {ExpressionStatement} */ (context.visit(attribute, child_state))
19-
);
20-
}
21-
}
22-
23-
const block = /** @type {BlockStatement} */ (context.visit(node.fragment, child_state));
24-
25-
context.state.template.push(block);
10+
context.state.template.push(/** @type {BlockStatement} */ (context.visit(node.fragment)));
2611
}

packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ export function serialize_element_attributes(node, context) {
3838
/** @type {StyleDirective[]} */
3939
const style_directives = [];
4040

41-
/** @type {ExpressionStatement[]} */
42-
const lets = [];
43-
4441
/** @type {Expression | null} */
4542
let content = null;
4643

@@ -185,7 +182,7 @@ export function serialize_element_attributes(node, context) {
185182
} else if (attribute.type === 'StyleDirective') {
186183
style_directives.push(attribute);
187184
} else if (attribute.type === 'LetDirective') {
188-
lets.push(/** @type {ExpressionStatement} */ (context.visit(attribute)));
185+
// do nothing, these are handled inside `serialize_inline_component`
189186
} else {
190187
context.visit(attribute);
191188
}
@@ -212,9 +209,6 @@ export function serialize_element_attributes(node, context) {
212209
}
213210
}
214211

215-
// Let bindings first, they can be used on attributes
216-
context.state.init.push(...lets);
217-
218212
if (has_spread) {
219213
serialize_element_spread_attributes(
220214
node,

0 commit comments

Comments
 (0)