-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
md-button attaches class "md-undefined" to host element when on color provided #75
Comments
Maybe it should have a default; |
My thought is to not include the class attribute if color is undefined, but I'm not sure how to modify the "host" metadata property in the component. Still learning angular2 to see how to get the component to not render with the class attribute if color is undefined. Do you guys know how? |
If returning an empty string still adds 'class' it could be an issue with Angular itself. |
If both
and
result in
I'd consider this an Angular bug. |
I've made a workaround for this. I'm not sure if it's good practice. Instead binding to the class property, I'm injecting ElementRef into the constructor.
This way no class attribute is rendered on the DOM, when there's no color property provided. What do you think? |
I even noticed now that when adding an extra class to a md-button, this class is overriden without the fix. ie:
results both in expected:
|
AFAIK using
as it prevents the code to run in webworker |
If binding to class doesn't work as expected I'd use |
@zoechi |
Sorry, forgot this is about host. |
So, what are the other options to prevent the problems stated above? |
I'd create a bug report for the behavior where |
Thanks to @zoechi at Stack Overflow I believe we've found a solution for two issues related to this one.
Drop [class] on host and add following code might be a solution:
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Given an html snippet with an md-button directive like so:
This produces the following ouput:
What it should produce is:
The
md-undefined
class is getting attached due to this code sincesetClassList()
returns"md-undefined"
when thecolor
attribute is unset.I tried working around the by returning an empty string when
color
is undefined, but that resulted in this html:Which is also invalid.
The text was updated successfully, but these errors were encountered: