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
Custom tagName Components don't work with boolean HTML attributes #10976
Comments
I'm marking this as a regression for now, but the behaviour of custom elements was never specified. |
I'll throw this in here in case it helps someone in the meantime: // There are two hard things in computer science...
Ember.computed.nullIfEmptyOrFalse = function(name) {
return Ember.computed(name, {
get: function() {
var val = Ember.get(this, name);
return !val || Ember.isEmpty(val) ?
null :
val;
}
});
}; |
in ember 1.13.3 (cli 1.13.1), |
Use |
ooohhh... 🐑.... (force wave) "I was never here" |
Did you guys hear something? |
I believe this is working as intended currently. Using Demo using |
HTML attributes on a custom element (Ember Component with custom
tagName
) don't work withattributeBindings
as expected. When trying to bind the disabled state of a custom element the attribute is not set correctly according to it's boolean value.Example
<button disabled={{isDisabled}}>
will work as expected but{{custom-button disabled=isDisabled}}
(withtagName: ‘custom-button’
) won't work as it produces<custom-button disabled=“false”>
(the presence of thedisabled
attribute means it’s disabled even though it's set to false).So the following Ember Component:
Output:
<custom-button disabled="false">Press Me</custom-button>
Expected:
<custom-button>Press Me</custom-button>
Here's a JSBin Example to illustrate the issue.
The behaviour seems to have changed in Ember 1.10/1.11. This JSBin shows the behaviour in Ember 1.9.1 where the disabled attribute never gets set to true. But I'm sure this used to work in our app before we upgrade so I'm a bit confused.
I chatted a bit with @mmun and it's likely because Ember uses
HTMLUnknownElement
for custom elements andattrName in elementInstance
to check if its a DOM property or not.The text was updated successfully, but these errors were encountered: