diff --git a/src/components/icon/icon.ts b/src/components/icon/icon.ts
index 38489c8102f..7468400c1e9 100644
--- a/src/components/icon/icon.ts
+++ b/src/components/icon/icon.ts
@@ -106,9 +106,10 @@ export class Icon extends Ion {
if (!(/^md-|^ios-|^logo-/.test(val))) {
// this does not have one of the defaults
// so lets auto add in the mode prefix for them
- val = this._iconMode + '-' + val;
+ this._name = this._iconMode + '-' + val;
+ } else {
+ this._name = val;
}
- this._name = val;
this.update();
}
@@ -161,34 +162,43 @@ export class Icon extends Ion {
* @private
*/
update() {
- let css = 'ion-';
-
- this._hidden = (this._name === null);
-
+ let name;
if (this._ios && this._iconMode === 'ios') {
- css += this._ios;
-
+ name = this._ios;
} else if (this._md && this._iconMode === 'md') {
- css += this._md;
-
+ name = this._md;
} else {
- css += this._name;
+ name = this._name;
}
-
- if (this._iconMode === 'ios' && !this.isActive && css.indexOf('logo') < 0) {
- css += '-outline';
+ let hidden = this._hidden = (name === null);
+ if (hidden) {
+ return;
}
- if (this._css !== css) {
- if (this._css) {
- this.setElementClass(this._css, false);
- }
- this._css = css;
- this.setElementClass(css, true);
+ let iconMode = name.split('-', 2)[0];
+ if (
+ iconMode === 'ios' &&
+ !this.isActive &&
+ name.indexOf('logo-') < 0 &&
+ name.indexOf('-outline') < 0) {
+ name += '-outline';
+ }
- this.setElementAttribute('aria-label',
- css.replace('ion-', '').replace('ios-', '').replace('md-', '').replace('-', ' '));
+ let css = 'ion-' + name;
+ if (this._css === css) {
+ return;
+ }
+ if (this._css) {
+ this.setElementClass(this._css, false);
}
+ this._css = css;
+ this.setElementClass(css, true);
+
+ let label = name
+ .replace('ios-', '')
+ .replace('md-', '')
+ .replace('-', ' ');
+ this.setElementAttribute('aria-label', label);
}
}
diff --git a/src/components/icon/test/basic/main.html b/src/components/icon/test/basic/main.html
index d68e2a5da1b..8c9304078e5 100644
--- a/src/components/icon/test/basic/main.html
+++ b/src/components/icon/test/basic/main.html
@@ -12,30 +12,37 @@
name="home"
- [name]="homeIcon"
+ name="home" isActive="true"
- name="home" isActive="true"
+ [name]="homeIcon" [isActive]="isActive" (false)
- name="home" [isActive]="isActive"
+ name="md-home" isActive="false"
+
+
+ name="ios-home" isActive="false"
+ name="ios-home-outline" isActive="false"
+
+
@@ -74,12 +88,34 @@
+ ios="md-color-filter" md="ios-color-filter"
+
+
+ ios="md-color-filter" md="ios-color-filter" isActive="false"
+
+
+ name="null"
+
+
ion-item w/ [detail-push] attr. text text text text text text
diff --git a/src/components/tabs/test/basic/app-module.ts b/src/components/tabs/test/basic/app-module.ts
index 3cc7f71d5a3..5721655c53d 100644
--- a/src/components/tabs/test/basic/app-module.ts
+++ b/src/components/tabs/test/basic/app-module.ts
@@ -237,8 +237,8 @@ export class Tab3 {