refactor(icon): improves logic for isActive

This commit is contained in:
Manu Mtz.-Almeida
2016-11-01 23:49:54 +01:00
parent 3fe3d98b0f
commit 06357dc441

View File

@ -1,5 +1,6 @@
import { Directive, ElementRef, HostBinding, Input, Renderer } from '@angular/core';
import { isTrueProperty } from '../../util/util';
import { Config } from '../../config/config';
import { Ion } from '../ion';
@ -45,7 +46,7 @@ export class Icon extends Ion {
/** @private */
_iconMode: string;
/** @private */
_isActive: any;
_isActive: boolean = true;
/** @private */
_name: string = '';
/** @private */
@ -145,11 +146,11 @@ export class Icon extends Ion {
*/
@Input()
get isActive(): boolean {
return (this._isActive === undefined || this._isActive === true || this._isActive === 'true');
return this._isActive;
}
set isActive(val: boolean) {
this._isActive = val;
this._isActive = isTrueProperty(val);
this.update();
}
@ -178,7 +179,7 @@ export class Icon extends Ion {
let iconMode = name.split('-', 2)[0];
if (
iconMode === 'ios' &&
!this.isActive &&
!this._isActive &&
name.indexOf('logo-') < 0 &&
name.indexOf('-outline') < 0) {
name += '-outline';