Skip to content
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

Normalize global boolean attrs values passed to custom elements as props #2012

Open
jodarove opened this issue Aug 20, 2020 · 0 comments
Open

Comments

@jodarove
Copy link
Contributor

Attribute values for custom elements that are set in the template are always set as properties; in the case of global boolean attributes (ex: hidden), there's a difference when the value passed is static vs the passed value being an expression:

  • When the value is static, ex: <x-foo hidden="3"> is transformed into hidden: true prop
  • When the attribute is set to an expression, ex: <x-foo hidden={bar}> the template is transformed into hidden: $cmp.bar prop.

The issue is that despite the hidden attr/prop only allows boolean values, when is set via an expression, it can be set to other values different than true or false.

Describe the solution you'd like
We should normalize the property value passed to the custom element, modifying the compiled code to hidden: !!$cmp.bar, in such way will match with how static attributes are converted to properties and will match the spec.

Note: today you can pass any value, therefore for a component with an api attribute hidden that is receiving other than boolean values, this change will be breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants