Skip to content

Commit 9823f91

Browse files
committed
finish up const tag work
1 parent 7714c93 commit 9823f91

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,7 @@ function serialize_inline_component(node, component_name, context) {
839839
}
840840
}
841841

842-
children[slot_name] = children[slot_name] || [];
843-
children[slot_name].push(child);
842+
(children[slot_name] ||= []).push(child);
844843
}
845844

846845
// Serialize each slot

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,10 @@ const template_visitors = {
13821382
node.fragment.nodes,
13831383
inner_context.path,
13841384
metadata.namespace,
1385-
context.state,
1385+
{
1386+
...context.state,
1387+
scope: /** @type {import('../../scope').Scope} */ (context.state.scopes.get(node.fragment))
1388+
},
13861389
state.preserve_whitespace,
13871390
state.options.preserveComments
13881391
);

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ function sort_const_tags(nodes, state) {
4040
* }} Tag
4141
*/
4242

43-
const const_tags = [];
4443
const other = [];
4544

4645
/** @type {Map<import('#compiler').Binding, Tag>} */
@@ -77,26 +76,22 @@ function sort_const_tags(nodes, state) {
7776
}
7877
}
7978
});
80-
81-
const_tags.push(tag);
8279
} else {
8380
other.push(node);
8481
}
8582
}
8683

87-
if (const_tags.length === 0) {
84+
if (tags.size === 0) {
8885
return nodes;
8986
}
9087

9188
/** @type {Array<[import('#compiler').Binding, import('#compiler').Binding]>} */
9289
const edges = [];
9390

94-
for (const tag of const_tags) {
95-
for (const id of tag.ids) {
96-
for (const dep of tag.deps) {
97-
if (tags.has(dep)) {
98-
edges.push([id, dep]);
99-
}
91+
for (const [id, tag] of tags) {
92+
for (const dep of tag.deps) {
93+
if (tags.has(dep)) {
94+
edges.push([id, dep]);
10095
}
10196
}
10297
}
@@ -124,7 +119,7 @@ function sort_const_tags(nodes, state) {
124119
sorted.push(tag.node);
125120
}
126121

127-
for (const tag of const_tags) {
122+
for (const tag of tags.values()) {
128123
add(tag);
129124
}
130125

0 commit comments

Comments
 (0)