Compare commits

...
2 Commits
Author SHA1 Message Date
Manu Mtz.-Almeida d8a17ea0db 4.5.3 2019-01-22 18:35:19 +01:00
Manu Mtz.-Almeida c9f08cd1c7 fix(aria): adds ariaLabel when using the icon prop 2019-01-22 18:34:38 +01:00
4 changed files with 40 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ionicons",
"version": "4.5.2",
"version": "4.5.3",
"description": "Premium icons for Ionic.",
"files": [
"dist/",
+13 -8
View File
@@ -1,5 +1,5 @@
import { Component, Element, Prop, State, Watch } from '@stencil/core';
import { getIconMap, getName, getSrc, isValid } from './utils';
import { getIconMap, getName, getSrc, isSrc, isValid } from './utils';
@Component({
tag: 'ion-icon',
@@ -132,7 +132,7 @@ export class Icon {
}
if (!this.ariaLabel) {
const name = getName(this.name, this.mode, this.ios, this.md);
const name = getName(this.getName(), this.mode, this.ios, this.md);
// user did not provide a label
// come up with the label based on the icon name
if (name) {
@@ -144,13 +144,23 @@ export class Icon {
}
}
getName() {
if (this.name !== undefined) {
return this.name;
}
if (this.icon && !isSrc(this.icon)) {
return this.icon;
}
return undefined;
}
getUrl() {
let url = getSrc(this.src);
if (url) {
return url;
}
url = getName(this.name, this.mode, this.ios, this.md);
url = getName(this.getName(), this.mode, this.ios, this.md);
if (url) {
return this.getNamedUrl(url);
}
@@ -160,11 +170,6 @@ export class Icon {
return url;
}
url = getName(this.icon, this.mode, this.ios, this.md);
if (url) {
return this.getNamedUrl(url);
}
return null;
}
+4 -1
View File
@@ -60,13 +60,16 @@ export function getName(
export function getSrc(src: string | undefined) {
if (typeof src === 'string') {
src = src.trim();
if (src.length > 0 && /(\/|\.)/.test(src)) {
if (isSrc(src)) {
return src;
}
}
return null;
}
export function isSrc(str: string) {
return str.length > 0 && /(\/|\.)/.test(str);
}
export function isValid(elm: HTMLElement) {
if (elm.nodeType === 1) {
+22
View File
@@ -71,6 +71,28 @@
<ion-icon icon="/ionicons/svg/md-image.svg"></ion-icon>
</section>
<section>
<code>
&lt;ion-icon icon="ios-baseball"&gt;&lt;/ion-icon&gt;
</code>
<ion-icon icon="ios-baseball"></ion-icon>
</section>
<section>
<code>
&lt;ion-icon icon="md-baseball"&gt;&lt;/ion-icon&gt;
</code>
<ion-icon icon="md-baseball"></ion-icon>
</section>
<section>
<code>
&lt;ion-icon icon="baseball"&gt;&lt;/ion-icon&gt;
</code>
<ion-icon icon="baseball"></ion-icon>
</section>
<section>
<code>
&lt;ion-icon name="ios-airplane"&gt;&lt;/ion-icon&gt;