You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: active-rfcs/0000-new-scoped-slots-syntax.md
-86Lines changed: 0 additions & 86 deletions
Original file line number
Diff line number
Diff line change
@@ -336,89 +336,3 @@ The change is fully backwards compatible, so we can roll it out in a minor relea
336
336
In 3.0 we do plan to eventually remove `slot-scope`, and only support the new syntax. We will start emitting deprecation messages for `slot-scope` usage in the next 2.x minor release to ease the migration to 3.0.
337
337
338
338
Since this is a pretty well defined syntax change, we can potentially provide a migration tool that can automatically convert your templates to the new syntax.
339
-
340
-
# Unresolved questions
341
-
342
-
### Shorthand Syntax
343
-
344
-
In a previous draft of this proposal, we proposed a shorthand for the new syntax:
345
-
346
-
```html
347
-
<foo()="{ msg }">
348
-
{{ msg }}
349
-
</foo>
350
-
351
-
<foo>
352
-
<template(header)="{ msg }">
353
-
Message from header: {{ msg }}
354
-
</template>
355
-
356
-
<template(footer)>
357
-
A static footer
358
-
</template>
359
-
</foo>
360
-
```
361
-
362
-
Here the `v-slot:arg` is translated into `(arg)`.
363
-
364
-
However, there were very mixed opinions on which symbol should be used for the shorthand, or whether a shorthand is needed at all. Two most favored alternative symbols for the shorthand are listed below:
365
-
366
-
### `#`
367
-
368
-
```html
369
-
<foo#="{ msg }">
370
-
{{ msg }}
371
-
</foo>
372
-
373
-
<foo>
374
-
<template#header="{ msg }">
375
-
Message from header: {{ msg }}
376
-
</template>
377
-
378
-
<template#footer>
379
-
A static footer
380
-
</template>
381
-
</foo>
382
-
```
383
-
384
-
### `&`
385
-
386
-
```html
387
-
<foo&="{ msg }">
388
-
{{ msg }}
389
-
</foo>
390
-
391
-
<foo>
392
-
<template&header="{ msg }">
393
-
Message from header: {{ msg }}
394
-
</template>
395
-
396
-
<template&footer>
397
-
A static footer
398
-
</template>
399
-
</foo>
400
-
```
401
-
402
-
Personally, I think a shorthand is a beneficial addition, as it makes the slot designation jump out from normal props and directives and makes the template easier to scan.
403
-
404
-
Some may argue that scoped slots are not that commonly used and therefore don't really need a shorthand. On that front, I actually believe scoped slot is an important mechanism for building 3rd party component suites that are highly customizable. For a user using a component collection with an API that relies heavily on slots, a shorthand will become quite valuable.
405
-
406
-
After the initial round of feedback I agree that `()` as the shorthand can be potentially confusing to beginners, and am now leaning towards `#`. Some examples of the usage in a real-world library that relies on scoped slots ([vue-promised](https://github.com/posva/vue-promised)):
0 commit comments