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
[12.x] provide a default slot name when compiling (#56883)
* provide a default slot name when compiling
currently it is required that a name be passed to a slot for a component via 1 of 3 methods:
```php
<x-slot:name></x-slot>
<x-slot name="name"></x-slot>
<x-slot :name="$name"></x-slot>
```
If you omit all of these options you currently get a syntax error due to an incorrectly compiled slot.
```php
<?php $__env->slot(, null, []); ?> slot <?php $__env->endSlot(); ?>
```
This commit adds a default slot name of "slot" if no others are given. This allows the user to omit designating a name if they wish to use the slot as the default, wich is available in the component as `$slot`.
This simple string of "slot" joins the "inline name" and "attribute name" in needing to be wrapped in single quotes, unlike the "bound name". In order to accomplish this I reversed the logic of the conditional change so instead of looking for either not empty "inline name" or not empty "attribute name", it looks for empty "bound name". the inversion of logic should behave the same, and gives a very small performance improvement.
* revert quote wrapping logic
these is a case when a user passes both the "bound name" and 1 of the other types, which screws up this inversion.
we'll move the short ternary outside of the `stripQuotes()` method, so we can explictly set our wrapped `'slot'` value.
* add test
0 commit comments