mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +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 { Directive, ElementRef, HostBinding, Input, Renderer } from '@angular/core';
|
||||||
|
|
||||||
|
import { isTrueProperty } from '../../util/util';
|
||||||
import { Config } from '../../config/config';
|
import { Config } from '../../config/config';
|
||||||
import { Ion } from '../ion';
|
import { Ion } from '../ion';
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ export class Icon extends Ion {
|
|||||||
/** @private */
|
/** @private */
|
||||||
_iconMode: string;
|
_iconMode: string;
|
||||||
/** @private */
|
/** @private */
|
||||||
_isActive: any;
|
_isActive: boolean = true;
|
||||||
/** @private */
|
/** @private */
|
||||||
_name: string = '';
|
_name: string = '';
|
||||||
/** @private */
|
/** @private */
|
||||||
@ -145,11 +146,11 @@ export class Icon extends Ion {
|
|||||||
*/
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
get isActive(): boolean {
|
get isActive(): boolean {
|
||||||
return (this._isActive === undefined || this._isActive === true || this._isActive === 'true');
|
return this._isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
set isActive(val: boolean) {
|
set isActive(val: boolean) {
|
||||||
this._isActive = val;
|
this._isActive = isTrueProperty(val);
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ export class Icon extends Ion {
|
|||||||
let iconMode = name.split('-', 2)[0];
|
let iconMode = name.split('-', 2)[0];
|
||||||
if (
|
if (
|
||||||
iconMode === 'ios' &&
|
iconMode === 'ios' &&
|
||||||
!this.isActive &&
|
!this._isActive &&
|
||||||
name.indexOf('logo-') < 0 &&
|
name.indexOf('logo-') < 0 &&
|
||||||
name.indexOf('-outline') < 0) {
|
name.indexOf('-outline') < 0) {
|
||||||
name += '-outline';
|
name += '-outline';
|
||||||
|
Reference in New Issue
Block a user