Skip to content

Commit d546f19

Browse files
committed
Make it work even if no spread props are used
1 parent 3b9fdf9 commit d546f19

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ export function SlotElement(node, context) {
5454
// Let bindings first, they can be used on attributes
5555
context.state.init.push(...lets);
5656

57-
const props_expression =
58-
spreads.length === 0 ? b.object(props) : b.call('$.spread_props', b.object(props), ...spreads);
57+
const props_expression = b.call('$.props', b.object(props), ...spreads);
5958

6059
const fallback =
6160
node.fragment.nodes.length === 0

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import { dev, is_ignored } from '../../../../../state.js';
55
import { get_attribute_chunks, object } from '../../../../../utils/ast.js';
66
import * as b from '#compiler/builders';
7-
import { build_bind_this, memoize_expression, validate_binding } from '../shared/utils.js';
8-
import { build_attribute_value } from '../shared/element.js';
7+
import { build_bind_this, memoize_expression, validate_binding } from './utils.js';
8+
import { build_attribute_value } from './element.js';
99
import { build_event_handler } from './events.js';
1010
import { determine_slot } from '../../../../../utils/slot.js';
1111

@@ -399,14 +399,10 @@ export function build_component(node, component_name, context) {
399399
push_prop(b.init('$$legacy', b.true));
400400
}
401401

402-
const props_expression =
403-
props_and_spreads.length === 0 ||
404-
(props_and_spreads.length === 1 && Array.isArray(props_and_spreads[0]))
405-
? b.object(/** @type {Property[]} */ (props_and_spreads[0]) || [])
406-
: b.call(
407-
'$.spread_props',
408-
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))
409-
);
402+
const props_expression = b.call(
403+
'$.props',
404+
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))
405+
);
410406

411407
/** @param {Expression} node_id */
412408
let fn = (node_id) => {

packages/svelte/src/internal/client/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export {
114114
prop,
115115
rest_props,
116116
legacy_rest_props,
117-
spread_props,
117+
props,
118118
update_pre_prop,
119119
update_prop
120120
} from './reactivity/props.js';

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const spread_props_handler = {
239239
* @param {Array<Record<string, unknown> | (() => Record<string, unknown>)>} props
240240
* @returns {any}
241241
*/
242-
export function spread_props(...props) {
242+
export function props(...props) {
243243
let destroyed = false;
244244
teardown(() => (destroyed = true));
245245
return new Proxy(

0 commit comments

Comments
 (0)