ignore button attr as button color

This commit is contained in:
Adam Bradley
2015-12-07 12:46:31 -06:00
parent 7506d197f3
commit 3fa93ac815
2 changed files with 12 additions and 4 deletions

View File

@@ -144,8 +144,8 @@ export class Button {
this._setClass(this._icon, assignCssClass); // button-icon-left
let colorStyle = (this._style && this._style !== 'solid' ? this._style + '-' : '');
this._colors.forEach(color => {
this._setClass(colorStyle + color, assignCssClass); // button-secondary
this._colors.forEach(colorName => {
this._setClass(colorStyle + colorName, assignCssClass); // button-secondary, button-clear-secondary
});
}
}
@@ -169,7 +169,7 @@ const BUTTON_SIZE_ATTRS = ['large', 'small'];
const BUTTON_STYLE_ATTRS = ['clear', 'outline', 'solid'];
const BUTTON_SHAPE_ATTRS = ['round', 'fab'];
const BUTTON_DISPLAY_ATTRS = ['block', 'full'];
const IGNORE_ATTRS = /_ng/;
const IGNORE_ATTRS = /_ng|button/;
const TEXT = 1;
const ICON = 2;

View File

@@ -24,9 +24,17 @@ export function run() {
return button.elementRef.nativeElement.classList.contains(className);
}
it('should ignore certain attributes', () => {
let b = mockButton(['_ngcontent', 'button']);
b._assignCss(true);
expect(hasClass(b, 'button')).toEqual(true);
expect(hasClass(b, 'button-_ngcontent')).toEqual(false);
expect(hasClass(b, 'button-button')).toEqual(false);
});
it('should set a different button role', () => {
let b = mockButton(['outline', 'small', 'full', 'primary']);
b.setRole('bar-button')
b.setRole('bar-button');
b._assignCss(true);
expect(hasClass(b, 'bar-button-outline')).toEqual(true);
expect(hasClass(b, 'bar-button-small')).toEqual(true);