diff --git a/src/components/badge/badge.ts b/src/components/badge/badge.ts index d46e1f9a796..3156d098f34 100644 --- a/src/components/badge/badge.ts +++ b/src/components/badge/badge.ts @@ -21,7 +21,7 @@ export class Badge extends Ion { */ @Input() set color(val: string) { - this._setColor('badge', val); + this._setColor(val); } /** @@ -29,11 +29,11 @@ export class Badge extends Ion { */ @Input() set mode(val: string) { - this._setMode('badge', val); + this._setMode(val); } constructor(config: Config, elementRef: ElementRef, renderer: Renderer) { - super(config, elementRef, renderer); + super(config, elementRef, renderer, 'badge'); this.mode = config.get('mode'); } diff --git a/src/components/ion.ts b/src/components/ion.ts index 227e03d6314..ecbfb3d0e6c 100644 --- a/src/components/ion.ts +++ b/src/components/ion.ts @@ -26,10 +26,16 @@ export class Ion { /** @private */ _mode: string; - constructor(config: Config, elementRef: ElementRef, renderer: Renderer) { + /** @private */ + _componentName: string; + + constructor(config: Config, elementRef: ElementRef, renderer: Renderer, componentName: string) { this._config = config; this._elementRef = elementRef; this._renderer = renderer; + this._componentName = componentName; + + this._setComponentName(); } /** @private */ @@ -48,32 +54,37 @@ export class Ion { } /** @private */ - _setColor(componentName: string, newColor: string) { + _setColor(newColor: string) { if (this._color) { - this.setElementClass(`${componentName}-${this._mode}-${this._color}`, false); + this.setElementClass(`${this._componentName}-${this._mode}-${this._color}`, false); } if (newColor) { - this.setElementClass(`${componentName}-${this._mode}-${newColor}`, true); + this.setElementClass(`${this._componentName}-${this._mode}-${newColor}`, true); this._color = newColor; } } /** @private */ - _setMode(componentName: string, newMode: string) { + _setMode(newMode: string) { if (this._mode) { - this.setElementClass(`${componentName}-${this._mode}`, false); + this.setElementClass(`${this._componentName}-${this._mode}`, false); } if (newMode) { - this.setElementClass(`${componentName}-${newMode}`, true); + this.setElementClass(`${this._componentName}-${newMode}`, true); // Remove the color class associated with the previous mode, // change the mode, then add the new color class - this._setColor(componentName, null); + this._setColor(null); this._mode = newMode; - this._setColor(componentName, this._color); + this._setColor(this._color); } } + /** @private */ + _setComponentName() { + this.setElementClass(this._componentName, true); + } + /** @private */ getElementRef(): ElementRef { return this._elementRef; diff --git a/src/components/item/item.ts b/src/components/item/item.ts index a174cafc75d..47c17be1cc3 100644 --- a/src/components/item/item.ts +++ b/src/components/item/item.ts @@ -321,11 +321,11 @@ export class Item extends Ion { */ @Input() set mode(val: string) { - this._setMode('item', val); + this._setMode(val); } constructor(form: Form, config: Config, elementRef: ElementRef, renderer: Renderer) { - super(config, elementRef, renderer); + super(config, elementRef, renderer, 'item'); this.mode = config.get('mode'); this.id = form.nextId().toString(); diff --git a/src/components/label/label.ts b/src/components/label/label.ts index 023f37166eb..eafd9ad8ab9 100644 --- a/src/components/label/label.ts +++ b/src/components/label/label.ts @@ -65,7 +65,7 @@ export class Label extends Ion { */ @Input() set color(val: string) { - this._setColor('label', val); + this._setColor(val); } /** @@ -73,7 +73,7 @@ export class Label extends Ion { */ @Input() set mode(val: string) { - this._setMode('label', val); + this._setMode(val); } /** @@ -90,7 +90,7 @@ export class Label extends Ion { @Attribute('fixed') isFixed: string, @Attribute('inset') isInset: string ) { - super(config, elementRef, renderer); + super(config, elementRef, renderer, 'label'); this.mode = config.get('mode'); this.type = (isFloating === '' ? 'floating' : (isStacked === '' ? 'stacked' : (isFixed === '' ? 'fixed' : (isInset === '' ? 'inset' : null))));