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
Using "similar" (null, true, false...) value give different result.
In particular:
if null is passed in array or as value give different results.
int 0 give empty result, int >0 give the number
The problem is trivial since in my case affect only TestClass for widget since when applying a class with null value result in an additional space and the resulting string do not match
Especially for null it gives a different result but in general the result is quite mixed for values that should give same result when casted to string.
(int) 0 should be same as (str) 0
true/false should produce in both cases ''
null passed as value or value in array should give same result
###Expected result
The expected result should be: <div class="base_class">
except for (int) 0 which should be <div class="base_class 0">
In the above case, starting a css class name with 0 or any number is invalid, but I do not know if there is any css framewrok doing so
Additional info
I think the best place to fix this behavior is in BaseHtml::mergeCssClasses
Here the code should drop empty values and eventually non valid css class name.
Personally I would avoid the second part (csss name validation) since this would make big problem with css framework like Tailwind.
Probably the best solution is to change the code of BaseHtml::mergeCssClasses to filter out empty and "only space" string value.
Applying the following array_filter before return fix it.
Using "similar" (null, true, false...) value give different result.
In particular:
if null is passed in array or as value give different results.
int 0 give empty result, int >0 give the number
The problem is trivial since in my case affect only TestClass for widget since when applying a class with null value result in an additional space and the resulting string do not match
What steps will reproduce the problem?
The below code compare the results
The above code give as result:
Especially for null it gives a different result but in general the result is quite mixed for values that should give same result when casted to string.
(int) 0 should be same as (str) 0
true/false should produce in both cases ''
null passed as value or value in array should give same result
###Expected result
The expected result should be:
<div class="base_class">
except for (int) 0 which should be
<div class="base_class 0">
In the above case, starting a css class name with 0 or any number is invalid, but I do not know if there is any css framewrok doing so
Additional info
I think the best place to fix this behavior is in BaseHtml::mergeCssClasses
Here the code should drop empty values and eventually non valid css class name.
Personally I would avoid the second part (csss name validation) since this would make big problem with css framework like Tailwind.
Probably the best solution is to change the code of BaseHtml::mergeCssClasses to filter out empty and "only space" string value.
Applying the following array_filter before return fix it.
The text was updated successfully, but these errors were encountered: