Skip to content

Commit 0c914eb

Browse files
committed
rename to attach
1 parent 2329284 commit 0c914eb

File tree

13 files changed

+55
-55
lines changed

13 files changed

+55
-55
lines changed

packages/svelte/src/compiler/phases/1-parse/state/element.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,24 +480,24 @@ function read_static_attribute(parser) {
480480

481481
/**
482482
* @param {Parser} parser
483-
* @returns {AST.Attribute | AST.SpreadAttribute | AST.Directive | AST.UseTag | null}
483+
* @returns {AST.Attribute | AST.SpreadAttribute | AST.Directive | AST.AttachTag | null}
484484
*/
485485
function read_attribute(parser) {
486486
const start = parser.index;
487487

488488
if (parser.eat('{')) {
489489
parser.allow_whitespace();
490490

491-
if (parser.eat('@use')) {
491+
if (parser.eat('@attach')) {
492492
parser.require_whitespace();
493493

494494
const expression = read_expression(parser);
495495
parser.allow_whitespace();
496496
parser.eat('}', true);
497497

498-
/** @type {AST.UseTag} */
498+
/** @type {AST.AttachTag} */
499499
const use = {
500-
type: 'UseTag',
500+
type: 'AttachTag',
501501
start,
502502
end: parser.index,
503503
expression

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function visit_component(node, context) {
7575
attribute.type !== 'LetDirective' &&
7676
attribute.type !== 'OnDirective' &&
7777
attribute.type !== 'BindDirective' &&
78-
attribute.type !== 'UseTag'
78+
attribute.type !== 'AttachTag'
7979
) {
8080
e.component_invalid_directive(attribute);
8181
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import { TitleElement } from './visitors/TitleElement.js';
5656
import { TransitionDirective } from './visitors/TransitionDirective.js';
5757
import { UpdateExpression } from './visitors/UpdateExpression.js';
5858
import { UseDirective } from './visitors/UseDirective.js';
59-
import { UseTag } from './visitors/UseTag.js';
59+
import { AttachTag } from './visitors/AttachTag.js';
6060
import { VariableDeclaration } from './visitors/VariableDeclaration.js';
6161

6262
/** @type {Visitors} */
@@ -132,7 +132,7 @@ const visitors = {
132132
TransitionDirective,
133133
UpdateExpression,
134134
UseDirective,
135-
UseTag,
135+
AttachTag,
136136
VariableDeclaration
137137
};
138138

packages/svelte/src/compiler/phases/3-transform/client/visitors/UseTag.js renamed to packages/svelte/src/compiler/phases/3-transform/client/visitors/AttachTag.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import * as b from '../../../../utils/builders.js';
55

66
/**
7-
* @param {AST.UseTag} node
7+
* @param {AST.AttachTag} node
88
* @param {ComponentContext} context
99
*/
10-
export function UseTag(node, context) {
10+
export function AttachTag(node, context) {
1111
context.state.init.push(
1212
b.stmt(
1313
b.call(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function RegularElement(node, context) {
8282
/** @type {AST.StyleDirective[]} */
8383
const style_directives = [];
8484

85-
/** @type {Array<AST.AnimateDirective | AST.BindDirective | AST.OnDirective | AST.TransitionDirective | AST.UseDirective | AST.UseTag>} */
85+
/** @type {Array<AST.AnimateDirective | AST.BindDirective | AST.OnDirective | AST.TransitionDirective | AST.UseDirective | AST.AttachTag>} */
8686
const other_directives = [];
8787

8888
/** @type {ExpressionStatement[]} */
@@ -153,7 +153,7 @@ export function RegularElement(node, context) {
153153
other_directives.push(attribute);
154154
break;
155155

156-
case 'UseTag':
156+
case 'AttachTag':
157157
other_directives.push(attribute);
158158
break;
159159
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ export function build_component(node, component_name, context, anchor = context.
252252
);
253253
}
254254
}
255-
} else if (attribute.type === 'UseTag') {
255+
} else if (attribute.type === 'AttachTag') {
256256
push_prop(
257257
b.prop(
258258
'init',
259-
b.call('Symbol', b.literal('@use')),
259+
b.call('Symbol', b.literal('@attach')),
260260
b.thunk(/** @type {Expression} */ (context.visit(attribute.expression))),
261261
true
262262
)

packages/svelte/src/compiler/types/template.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ export namespace AST {
174174
};
175175
}
176176

177-
/** A `{@use foo(...)} tag */
178-
export interface UseTag extends BaseNode {
179-
type: 'UseTag';
177+
/** A `{@attach foo(...)} tag */
178+
export interface AttachTag extends BaseNode {
179+
type: 'AttachTag';
180180
expression: Expression;
181181
}
182182

@@ -279,7 +279,7 @@ export namespace AST {
279279

280280
interface BaseElement extends BaseNode {
281281
name: string;
282-
attributes: Array<Attribute | SpreadAttribute | Directive | UseTag>;
282+
attributes: Array<Attribute | SpreadAttribute | Directive | AttachTag>;
283283
fragment: Fragment;
284284
}
285285

@@ -553,7 +553,7 @@ export namespace AST {
553553
| AST.Attribute
554554
| AST.SpreadAttribute
555555
| Directive
556-
| AST.UseTag
556+
| AST.AttachTag
557557
| AST.Comment
558558
| Block;
559559

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div {@use (node) => {}} {@use (node) => {}}></div>
1+
<div {@attach (node) => {}} {@attach (node) => {}}></div>

packages/svelte/tests/parser-modern/samples/attachments/output.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22
"css": null,
33
"js": [],
44
"start": 0,
5-
"end": 51,
5+
"end": 57,
66
"type": "Root",
77
"fragment": {
88
"type": "Fragment",
99
"nodes": [
1010
{
1111
"type": "RegularElement",
1212
"start": 0,
13-
"end": 51,
13+
"end": 57,
1414
"name": "div",
1515
"attributes": [
1616
{
17-
"type": "UseTag",
17+
"type": "AttachTag",
1818
"start": 5,
19-
"end": 24,
19+
"end": 27,
2020
"expression": {
2121
"type": "ArrowFunctionExpression",
22-
"start": 11,
23-
"end": 23,
22+
"start": 14,
23+
"end": 26,
2424
"loc": {
2525
"start": {
2626
"line": 1,
27-
"column": 11
27+
"column": 14
2828
},
2929
"end": {
3030
"line": 1,
31-
"column": 23
31+
"column": 26
3232
}
3333
},
3434
"id": null,
@@ -38,55 +38,55 @@
3838
"params": [
3939
{
4040
"type": "Identifier",
41-
"start": 12,
42-
"end": 16,
41+
"start": 15,
42+
"end": 19,
4343
"loc": {
4444
"start": {
4545
"line": 1,
46-
"column": 12
46+
"column": 15
4747
},
4848
"end": {
4949
"line": 1,
50-
"column": 16
50+
"column": 19
5151
}
5252
},
5353
"name": "node"
5454
}
5555
],
5656
"body": {
5757
"type": "BlockStatement",
58-
"start": 21,
59-
"end": 23,
58+
"start": 24,
59+
"end": 26,
6060
"loc": {
6161
"start": {
6262
"line": 1,
63-
"column": 21
63+
"column": 24
6464
},
6565
"end": {
6666
"line": 1,
67-
"column": 23
67+
"column": 26
6868
}
6969
},
7070
"body": []
7171
}
7272
}
7373
},
7474
{
75-
"type": "UseTag",
76-
"start": 25,
77-
"end": 44,
75+
"type": "AttachTag",
76+
"start": 28,
77+
"end": 50,
7878
"expression": {
7979
"type": "ArrowFunctionExpression",
80-
"start": 31,
81-
"end": 43,
80+
"start": 37,
81+
"end": 49,
8282
"loc": {
8383
"start": {
8484
"line": 1,
85-
"column": 31
85+
"column": 37
8686
},
8787
"end": {
8888
"line": 1,
89-
"column": 43
89+
"column": 49
9090
}
9191
},
9292
"id": null,
@@ -96,33 +96,33 @@
9696
"params": [
9797
{
9898
"type": "Identifier",
99-
"start": 32,
100-
"end": 36,
99+
"start": 38,
100+
"end": 42,
101101
"loc": {
102102
"start": {
103103
"line": 1,
104-
"column": 32
104+
"column": 38
105105
},
106106
"end": {
107107
"line": 1,
108-
"column": 36
108+
"column": 42
109109
}
110110
},
111111
"name": "node"
112112
}
113113
],
114114
"body": {
115115
"type": "BlockStatement",
116-
"start": 41,
117-
"end": 43,
116+
"start": 47,
117+
"end": 49,
118118
"loc": {
119119
"start": {
120120
"line": 1,
121-
"column": 41
121+
"column": 47
122122
},
123123
"end": {
124124
"line": 1,
125-
"column": 43
125+
"column": 49
126126
}
127127
},
128128
"body": []
@@ -138,4 +138,4 @@
138138
]
139139
},
140140
"options": null
141-
}
141+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div {@use (node) => node.textContent = node.nodeName}></div>
1+
<div {@attach (node) => node.textContent = node.nodeName}></div>

0 commit comments

Comments
 (0)