mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
refactor(icon): improves logic for isActive
This commit is contained in:
@ -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';
|
||||
|
Reference in New Issue
Block a user