Skip to content

Commit 4a3fc9d

Browse files
committed
remove instruction.args
1 parent 324bd8a commit 4a3fc9d

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ export function template_to_functions(items) {
5252
last_current_element = elements_stack.at(-1);
5353
break;
5454
case 'create_element':
55-
last_current_element = create_element(args[0]);
55+
last_current_element = create_element(instruction.name);
5656
push(last_current_element);
5757
break;
5858
case 'create_text':
5959
push(create_text(last_element_stack, args[0]));
6060
break;
6161
case 'create_anchor':
62-
push(create_anchor(last_element_stack, args[0]));
62+
push(create_anchor(last_element_stack, instruction.data));
6363
break;
6464
case 'set_prop':
65-
set_prop(/** @type {Element} */ (last_current_element), args[0], args[1]);
65+
set_prop(/** @type {Element} */ (last_current_element), instruction.key, instruction.value);
6666
break;
6767
}
6868
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function template_to_string(items) {
4949
case 'create_element':
5050
last_current_element = insert({
5151
kind: 'element',
52-
element: instruction.args[0]
52+
element: instruction.name
5353
});
5454
break;
5555
case 'create_text':
@@ -61,14 +61,13 @@ export function template_to_string(items) {
6161
case 'create_anchor':
6262
insert({
6363
kind: 'anchor',
64-
data: instruction.args?.[0]
64+
data: instruction.data
6565
});
6666
break;
6767
case 'set_prop': {
6868
const el = /** @type {Element} */ (last_current_element);
69-
const [prop, value] = instruction.args;
7069
el.props ??= {};
71-
el.props[prop] = escape_html(value, true);
70+
el.props[instruction.key] = escape_html(instruction.value, true);
7271
break;
7372
}
7473
}

packages/svelte/src/compiler/phases/3-transform/client/types.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@ export interface ClientTransformState extends TransformState {
3939
type TemplateOperations = Array<
4040
| {
4141
kind: 'create_element';
42-
args: string[];
42+
name: string;
4343
}
4444
| {
4545
kind: 'create_text';
4646
args: string[];
4747
}
4848
| {
4949
kind: 'create_anchor';
50-
args?: string[];
50+
data?: string;
5151
}
5252
| {
5353
kind: 'set_prop';
54-
args: string[];
54+
key: string;
55+
value: string | undefined;
5556
}
5657
| {
5758
kind: 'push_element';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
*/
88
export function Comment(node, context) {
99
// We'll only get here if comments are not filtered out, which they are unless preserveComments is true
10-
context.state.template.push({ kind: 'create_anchor', args: [node.data] });
10+
context.state.template.push({ kind: 'create_anchor', data: node.data });
1111
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function RegularElement(node, context) {
5454
if (node.name === 'noscript') {
5555
context.state.template.push({
5656
kind: 'create_element',
57-
args: ['noscript']
57+
name: 'noscript'
5858
});
5959
return;
6060
}
@@ -77,7 +77,7 @@ export function RegularElement(node, context) {
7777

7878
context.state.template.push({
7979
kind: 'create_element',
80-
args: [node.name]
80+
name: node.name
8181
});
8282

8383
/** @type {Array<AST.Attribute | AST.SpreadAttribute>} */
@@ -118,7 +118,8 @@ export function RegularElement(node, context) {
118118
if (value.type === 'Literal' && typeof value.value === 'string') {
119119
context.state.template.push({
120120
kind: 'set_prop',
121-
args: ['is', value.value]
121+
key: 'is',
122+
value: value.value
122123
});
123124
continue;
124125
}
@@ -301,9 +302,9 @@ export function RegularElement(node, context) {
301302
if (name !== 'class' || value) {
302303
context.state.template.push({
303304
kind: 'set_prop',
304-
args: [attribute.name].concat(
305-
is_boolean_attribute(name) && value === true ? [] : [value === true ? '' : value]
306-
)
305+
key: attribute.name,
306+
value:
307+
is_boolean_attribute(name) && value === true ? undefined : value === true ? '' : value
307308
});
308309
}
309310
} else if (name === 'autofocus') {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,14 @@ export function build_component(node, component_name, context, anchor = context.
446446
const template_operations = [];
447447
if (context.state.metadata.namespace === 'svg') {
448448
// this boils down to <g><!></g>
449-
template_operations.push({ kind: 'create_element', args: ['g'] });
449+
template_operations.push({ kind: 'create_element', name: 'g' });
450450
template_operations.push({ kind: 'push_element' });
451451
template_operations.push({ kind: 'create_anchor' });
452452
template_operations.push({ kind: 'pop_element' });
453453
} else {
454454
// this boils down to <svelte-css-wrapper style='display: contents'><!></svelte-css-wrapper>
455-
template_operations.push({ kind: 'create_element', args: ['svelte-css-wrapper'] });
456-
template_operations.push({ kind: 'set_prop', args: ['style', 'display: contents'] });
455+
template_operations.push({ kind: 'create_element', name: 'svelte-css-wrapper' });
456+
template_operations.push({ kind: 'set_prop', key: 'style', value: 'display: contents' });
457457
template_operations.push({ kind: 'push_element' });
458458
template_operations.push({ kind: 'create_anchor' });
459459
template_operations.push({ kind: 'pop_element' });

0 commit comments

Comments
 (0)