Skip to content

Commit e358a4f

Browse files
authored
merge feature-7.0
Feature 7.0
2 parents f2ed84a + 0f6c84f commit e358a4f

File tree

6 files changed

+17
-88
lines changed

6 files changed

+17
-88
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [7.0.0](https://github.com/ionic-team/ionicons/compare/v6.1.3...v7.0.0) (2023-03-07)
7+
8+
**Migration Note:** Developers should ensure that their `<ion-icon>` usages have either `aria-label` or `aria-hidden` to avoid accessibility issues. See https://ionic.io/ionicons/usage for more information.
9+
10+
### Bug Fixes
11+
12+
* **icon:** remove auto-generated aria-label ([#1170](https://github.com/ionic-team/ionicons/issues/1170)) ([98975ec](https://github.com/ionic-team/ionicons/commit/98975ec0f54b825c33f528683834a5e38298d598))
13+
14+
15+
16+
617
## [6.1.3](https://github.com/ionic-team/ionicons/compare/v6.1.2...v6.1.3) (2023-02-09)
718

819

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"./"
44
],
5-
"version": "6.1.3"
5+
"version": "7.0.0"
66
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ionicons",
3-
"version": "6.1.3",
3+
"version": "7.0.0",
44
"description": "Premium icons for Ionic.",
55
"files": [
66
"components/",

src/components/icon/icon.tsx

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export class Icon {
1717

1818
@State() private svgContent?: string;
1919
@State() private isVisible = false;
20-
@State() private ariaLabel?: string;
2120

2221
/**
2322
* The mode determines which platform styles to use.
@@ -123,12 +122,6 @@ export class Icon {
123122
}
124123
}
125124

126-
private hasAriaHidden = () => {
127-
const { el } = this;
128-
129-
return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';
130-
};
131-
132125
@Watch('name')
133126
@Watch('src')
134127
@Watch('icon')
@@ -149,34 +142,18 @@ export class Icon {
149142
}
150143
}
151144

152-
const label = (this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md));
153-
154-
/**
155-
* Come up with a default label
156-
* in case user does not provide their own.
157-
*/
158-
if (label) {
159-
this.ariaLabel = label.replace(/\-/g, ' ');
160-
}
145+
this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md);
161146
}
162147

163148
render() {
164-
const { iconName, ariaLabel, el, inheritedAttributes } = this;
149+
const { iconName, el, inheritedAttributes } = this;
165150
const mode = this.mode || 'md';
166151
const flipRtl =
167152
this.flipRtl ||
168153
(iconName && (iconName.indexOf('arrow') > -1 || iconName.indexOf('chevron') > -1) && this.flipRtl !== false);
169154

170-
/**
171-
* Only set the aria-label if a) we have generated
172-
* one for the icon and if aria-hidden is not set to "true".
173-
* If developer wants to set their own aria-label, then
174-
* inheritedAttributes down below will override whatever
175-
* default label we have set.
176-
*/
177155
return (
178156
<Host
179-
aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null}
180157
role="img"
181158
class={{
182159
[mode]: true,

src/components/icon/test/icon.spec.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ describe('icon', () => {
1616
`);
1717
});
1818

19-
it('renders aria-hidden and no aria-label', async () => {
20-
const { root } = await newSpecPage({
21-
components: [Icon],
22-
html: `<ion-icon aria-hidden="true"></ion-icon>`,
23-
});
24-
expect(root).toEqualHtml(`
25-
<ion-icon class="md" role="img" aria-hidden="true">
26-
<mock:shadow-root>
27-
<div class="icon-inner"></div>
28-
</mock:shadow-root>
29-
</ion-icon>
30-
`);
31-
});
32-
3319
it('renders rtl with aria-hidden', async () => {
3420
const { root } = await newSpecPage({
3521
components: [Icon],
@@ -46,21 +32,6 @@ describe('icon', () => {
4632
`);
4733
});
4834

49-
it('renders default aria-label', async () => {
50-
const { root } = await newSpecPage({
51-
components: [Icon],
52-
html: `<ion-icon name="chevron-forward"></ion-icon>`,
53-
});
54-
55-
expect(root).toEqualHtml(`
56-
<ion-icon class="md" name="chevron-forward" role="img" aria-label="chevron forward">
57-
<mock:shadow-root>
58-
<div class="icon-inner"></div>
59-
</mock:shadow-root>
60-
</ion-icon>
61-
`);
62-
});
63-
6435
it('renders custom aria-label', async () => {
6536
const { root } = await newSpecPage({
6637
components: [Icon],
@@ -105,34 +76,4 @@ describe('icon', () => {
10576
</ion-icon>
10677
`);
10778
});
108-
109-
it('renders default label after changing source', async () => {
110-
const page = await newSpecPage({
111-
components: [Icon],
112-
html: `<ion-icon name="chevron-forward"></ion-icon>`,
113-
});
114-
115-
const icon = page.root;
116-
117-
expect(icon).toEqualHtml(`
118-
<ion-icon class="md" name="chevron-forward" role="img" aria-label="chevron forward">
119-
<mock:shadow-root>
120-
<div class="icon-inner"></div>
121-
</mock:shadow-root>
122-
</ion-icon>
123-
`);
124-
125-
if (icon) {
126-
icon.name = 'trash';
127-
}
128-
await page.waitForChanges();
129-
130-
expect(icon).toEqualHtml(`
131-
<ion-icon class="md" name="trash" role="img" aria-label="trash">
132-
<mock:shadow-root>
133-
<div class="icon-inner"></div>
134-
</mock:shadow-root>
135-
</ion-icon>
136-
`);
137-
});
13879
});

0 commit comments

Comments
 (0)