Skip to content

Commit 3441004

Browse files
committed
remove spread support
1 parent 3ae0c80 commit 3441004

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { SvelteFragment } from './visitors/SvelteFragment.js';
6060
import { SvelteHead } from './visitors/SvelteHead.js';
6161
import { SvelteSelf } from './visitors/SvelteSelf.js';
6262
import { SvelteWindow } from './visitors/SvelteWindow.js';
63+
import { SvelteBoundary } from './visitors/SvelteBoundary.js';
6364
import { TaggedTemplateExpression } from './visitors/TaggedTemplateExpression.js';
6465
import { Text } from './visitors/Text.js';
6566
import { TitleElement } from './visitors/TitleElement.js';
@@ -171,6 +172,7 @@ const visitors = {
171172
SvelteHead,
172173
SvelteSelf,
173174
SvelteWindow,
175+
SvelteBoundary,
174176
TaggedTemplateExpression,
175177
Text,
176178
TransitionDirective,

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

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,19 @@ export function SvelteBoundary(node, context) {
1111
const nodes = [];
1212
/** @type {Statement[]} */
1313
const snippet_statements = [];
14-
/** @type {Array<Property[] | Expression>} */
15-
const props_and_spreads = [];
16-
17-
let has_spread = false;
14+
/** @type {Array<Property[]>} */
15+
const props = [];
1816

1917
const push_prop = (/** @type {Property} */ prop) => {
20-
let current = props_and_spreads.at(-1);
18+
let current = props.at(-1);
2119
if (Array.isArray(current)) {
2220
current.push(prop);
2321
}
2422
const arr = [prop];
25-
props_and_spreads.push(arr);
23+
props.push(arr);
2624
};
2725

2826
for (const attribute of node.attributes) {
29-
if (attribute.type === 'SpreadAttribute') {
30-
const value = /** @type {Expression} */ (context.visit(attribute.expression, context.state));
31-
has_spread = true;
32-
33-
if (attribute.metadata.expression.has_state) {
34-
props_and_spreads.push(b.thunk(value));
35-
} else {
36-
props_and_spreads.push(value);
37-
}
38-
continue;
39-
}
40-
4127
// Skip non-attributes with a single value
4228
if (
4329
attribute.type !== 'Attribute' ||
@@ -87,16 +73,7 @@ export function SvelteBoundary(node, context) {
8773
)
8874
);
8975

90-
const props_expression =
91-
!has_spread && Array.isArray(props_and_spreads[0])
92-
? b.object(props_and_spreads[0])
93-
: props_and_spreads.length === 0
94-
? b.object([])
95-
: b.call(
96-
'$.spread_props',
97-
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))
98-
);
99-
76+
const props_expression = b.object(props.length === 0 ? [] : props[0]);
10077
const boundary = b.stmt(
10178
b.call('$.boundary', context.state.node, b.arrow([b.id('$$anchor')], block), props_expression)
10279
);

packages/svelte/tests/runtime-runes/samples/error-boundary-11/main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let props = $state({ onerror: (e) => console.log('error caught') });
88
</script>
99

10-
<svelte:boundary {...props}>
10+
<svelte:boundary onerror={props.onerror}>
1111
{count > 0 ? throw_error() : null}
1212
</svelte:boundary>
1313

0 commit comments

Comments
 (0)