[12.x] provide a default slot name when compiling #56883
Merged
+8
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
currently it is required that a name be passed to a slot for a component via 1 of 3 methods:
If you omit all of these options you currently get a syntax error due to an incorrectly compiled slot.
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, which is available in the component as
$slot
.compiles to:
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.
I could see someone making the argument this should be sent to master. Even though it was never documented, I'm considering it more as a bug fix, as using it this way in the past would have resulted in an error. Happy to resubmit though.