Skip to content

[6.x] Keep true and false strings in component attributes from Antlers - #15626

Open
jacksleight wants to merge 1 commit into
statamic:6.xfrom
jacksleight:fix/antlers-component-boolean-strings
Open

jacksleight wants to merge 1 commit into
statamic:6.xfrom
jacksleight:fix/antlers-component-boolean-strings

Conversation

@jacksleight

Copy link
Copy Markdown
Contributor

This PR keeps "true" and "false" as strings when they're passed as attributes to components from Antlers, the same as Blade.

Tag parameters turn those strings into booleans, which is right for tags but not for HTML attributes, where the literal value matters:

<x-icon aria-hidden="true" />
<x-button aria-expanded="false" />
<svg aria-hidden="aria-hidden">...</svg>
<button>...</button>

aria-hidden="aria-hidden" isn't a valid ARIA value, and aria-expanded="false" is dropped completely. Blade passes both through as written.

Notes:

  • Only the attribute bag keeps the strings, props still receive booleans, so <x-alert dismissible="false" /> behaves as it does now.
  • Bound values that resolve to the strings "true" or "false" are kept too, real booleans are unchanged (:hidden="is_hidden" still renders hidden="hidden").
  • This touches ComponentProxy like [6.x] Escape bound attributes passed to components from Antlers #15624, so there may be a small conflict depending on which goes in first.

This branch has not been deployed

No deployments
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.

1 participant