Skip to content

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

Merged
taylorotwell merged 4 commits into
9.xfrom
fix/short-blade-syntax
Oct 5, 2022
Merged

[9.x] Fixes issue using static class properties as blade attributes#44473
taylorotwell merged 4 commits into
9.xfrom
fix/short-blade-syntax

Conversation

@joedixon

@joedixon joedixon commented Oct 5, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

joedixon commented Oct 5, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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