-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blade slots no longer accept "falsy" values #38542
Comments
Ping @danharrin |
I have setup a Repo for the falsy values: https://github.com/Jubeki/laravel-bug-report-38542 The dump output is as follows: @component('components.component-with-slots')
@slot('falsySlot', null)
{{-- Dump: "" --}}
@endcomponent
@component('components.component-with-slots')
@slot('falsySlot', 0)
{{-- Dump: "" --}}
@endcomponent
@component('components.component-with-slots')
@slot('falsySlot', '')
{{-- Dump: "" --}}
@endcomponent
@component('components.component-with-slots')
@slot('falsySlot', [])
{{-- Dump: "" --}}
@endcomponent
@component('components.component-with-slots')
@slot('falsySlot', 'TEST')
{{-- Dump: "TEST" --}}
@endcomponent
@component('components.component-with-slots')
@slot('falsySlot', 5)
{{-- Dump: 5 --}}
@endcomponent It seems to be converting the values to empty strings. |
* Update slot pattern * Add attributes params to existing tests * Create ComponentSlot class * Pass attributes from slot tag to Blade directive * Compile slot attributes into slot object * Add compilation tests for attribute support * Remove unused exception * Reorder arguments * Fix dynamic components with slot attributes * Escape bound attributes for slots * Update BladeComponentTagCompilerTest.php * formattinG Co-authored-by: Taylor Otwell <taylorotwell@gmail.com>
Checking now and will submit another PR. One issue we have is that many parts of Blade are not currently testable, and this is one of them. |
@browner12 @Jubeki can you please check if #38546 fixes this? |
Yes can confirm that it now is working as intended. |
It does. It seems like a good hotfix for now, but at first glance it seems like this may be prime for other issues in the future. I'll admit I'm not super familiar with this code, though, so I'll have to dig in more. Thanks for figuring this out! |
Eh it's not much of a "hotfix" as this is how the framework did this check before my PR - unless you're referring to the lack of tests. |
hah, yah mostly referring to the fact that relying on the number of arguments passed is probably gonna cause us issues in the future.... I've got no other solution right now, so I'm happy with this solution! |
Description:
Blade component slots no longer accept "falsy" values (
null
,''
,0
,false
,[]
).For example:
@slot('enabled', null)
@slot('enabled', '')
@slot('enabled', 0)
@slot('enabled', false)
@slot('enabled', [])
This causes the templating/layout system to break, which results in a messed up HTML output.
Reverting to Laravel 8.55.0 fixes the problem. My guess is this is caused by the changes to Blade in PR #38372.
Steps To Reproduce:
In a view, use a component that has a falsy value in a slot.
The text was updated successfully, but these errors were encountered: