diff --git a/ionic/components/button/button.ts b/ionic/components/button/button.ts index 1c846fa9d0..f70ac17c63 100644 --- a/ionic/components/button/button.ts +++ b/ionic/components/button/button.ts @@ -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; diff --git a/ionic/components/button/test/button.spec.ts b/ionic/components/button/test/button.spec.ts index c1c81e4a19..e2a4e2f7aa 100644 --- a/ionic/components/button/test/button.spec.ts +++ b/ionic/components/button/test/button.spec.ts @@ -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);