Skip to content

Conversation

@NickSdot
Copy link
Contributor

@NickSdot NickSdot commented Oct 21, 2025

Closes #57463
Related #31994

 @php($foo = "")
 <x-link :title="$foo">Blub</x-link>
<a {{ $attributes }}>Blub</a>

renders as

<a title>Blub</a>

which is wrong. Title isn't a boolean attribute. It should be

<a>Blub</a>

We only ever want to have empty strings or whitespace-only strings in these situations:

  • alt
  • value
  • data-*

Never for title, rel, placeholder, class etc.

Everything in our #57235 supi dupi mega thread points to that we want Laravel data attributes to be somewhat aligned with what Vue does (cc @timacdonald). So, if we want that, we should start here. Though, Vue doesn't allow :title="item.value" so the exceptions I added only make sense but Vue doesn't have them. That said, given how Blade component attributes work, I believe we surely don't want to introduce a whole new defaults-concept in #57235, but mirror what we already have in Blade component attributes. Not sure if Tim agrees, but I believe consistency within the framework is more important than what Vue does (this is mainly about boolean behaviour) . So, if this is merged we have one thing less to worry about in the other PR.

@taylorotwell
Copy link
Member

@NickSdot how does this align with my comment on the @maybe PR?

Personally I think we should just follow what @timacdonald suggested on this, while leaning towards Vue for behavior where there are differences. 👍

@NickSdot
Copy link
Contributor Author

@NickSdot how does this align with my comment on the @maybe PR?

Personally I think we should just follow what @timacdonald suggested on this, while leaning towards Vue for behavior where there are differences. 👍

It adjusts empty/whitespace strings towards Vue like Tim suggested there. 👍

@timacdonald mind to confirm that you would agree on the exceptions I added?

Though, Vue doesn't allow :title="item.value" so the exceptions I added only make sense but Vue doesn't have them.


I didn't touch booleans in here. That sounds like a much bigger breaking change and given how controversial (🤯) it is in the @maybe PR we might not wanna do that? But that's your call.

I somewhat think and hope Tim will agree on the boolean stuff when he saw the last context I added after his proposal.

Anyway, that's not really relevant for this one. Can follow up later. 🤝

@NickSdot
Copy link
Contributor Author

I preferred to close the @maybe PR. However, this one stands on its own since the current behaviour is broken either way.

For completeness: Tim might want to replace this fix with Blade::compileAttribute() later in case you go forward with his proposal. But I believe the behaviour wouldn't be any different. 🙏

@taylorotwell taylorotwell marked this pull request as draft October 24, 2025 14:42
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.

2 participants