Skip to content

[9.x] Fixes issue using static class properties as blade attributes #44473

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

Merged
merged 4 commits into from
Oct 5, 2022

Conversation

joedixon
Copy link
Contributor

@joedixon joedixon commented Oct 5, 2022

The PR resolves #44465 which raises a breaking change where static class properties can no longer be passed to blade attributes since v9.32.0 when short syntax was introduced.

The fix updates the regex used to determine whether short syntax is being used.

Currently the regex looks for the sequence :$ within the component string. This successfully determines the short syntax, but will also match calls to a static class property, for example User: :$ id

To resolve this issue, \s has been added to the beginning of the regex to ensure there is whitespace before the : character.

@joedixon joedixon force-pushed the fix/short-blade-syntax branch from f4b8b7d to 14c8de2 Compare October 5, 2022 10:58
@PerryvanderMeer
Copy link
Contributor

Seems like this breaks a component with multiple attributes, because it removes the leading white-space character.

{{-- works --}}
<x-alert :$title/>

{{-- broken --}}
<x-alert type="info" :$title/>

@joedixon
Copy link
Contributor Author

joedixon commented Oct 5, 2022

Seems like this breaks a component with multiple attributes, because it removes the leading white-space character.

Great spot @PerryvanderMeer! Just pushed an update - is the working for you now?

@PerryvanderMeer
Copy link
Contributor

Looks good to me @joedixon 🚀
Maybe we should add some tests for components with multiple attributes, since all current tests rely on only one attribute?

@taylorotwell taylorotwell merged commit e37e6e0 into 9.x Oct 5, 2022
@taylorotwell taylorotwell deleted the fix/short-blade-syntax branch October 5, 2022 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New blade syntax breaks passing in static variables as attribute.
4 participants