Skip to content

Commit

Permalink
merge feature-7.0
Browse files Browse the repository at this point in the history
Feature 7.0
  • Loading branch information
liamdebeasi authored Mar 7, 2023
2 parents f2ed84a + 0f6c84f commit e358a4f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 88 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [7.0.0](https://github.com/ionic-team/ionicons/compare/v6.1.3...v7.0.0) (2023-03-07)

**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.

### Bug Fixes

* **icon:** remove auto-generated aria-label ([#1170](https://github.com/ionic-team/ionicons/issues/1170)) ([98975ec](https://github.com/ionic-team/ionicons/commit/98975ec0f54b825c33f528683834a5e38298d598))




## [6.1.3](https://github.com/ionic-team/ionicons/compare/v6.1.2...v6.1.3) (2023-02-09)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"packages": [
"./"
],
"version": "6.1.3"
"version": "7.0.0"
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ionicons",
"version": "6.1.3",
"version": "7.0.0",
"description": "Premium icons for Ionic.",
"files": [
"components/",
Expand Down
27 changes: 2 additions & 25 deletions src/components/icon/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class Icon {

@State() private svgContent?: string;
@State() private isVisible = false;
@State() private ariaLabel?: string;

/**
* The mode determines which platform styles to use.
Expand Down Expand Up @@ -123,12 +122,6 @@ export class Icon {
}
}

private hasAriaHidden = () => {
const { el } = this;

return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';
};

@Watch('name')
@Watch('src')
@Watch('icon')
Expand All @@ -149,34 +142,18 @@ export class Icon {
}
}

const label = (this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md));

/**
* Come up with a default label
* in case user does not provide their own.
*/
if (label) {
this.ariaLabel = label.replace(/\-/g, ' ');
}
this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md);
}

render() {
const { iconName, ariaLabel, el, inheritedAttributes } = this;
const { iconName, el, inheritedAttributes } = this;
const mode = this.mode || 'md';
const flipRtl =
this.flipRtl ||
(iconName && (iconName.indexOf('arrow') > -1 || iconName.indexOf('chevron') > -1) && this.flipRtl !== false);

/**
* Only set the aria-label if a) we have generated
* one for the icon and if aria-hidden is not set to "true".
* If developer wants to set their own aria-label, then
* inheritedAttributes down below will override whatever
* default label we have set.
*/
return (
<Host
aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null}
role="img"
class={{
[mode]: true,
Expand Down
59 changes: 0 additions & 59 deletions src/components/icon/test/icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ describe('icon', () => {
`);
});

it('renders aria-hidden and no aria-label', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `<ion-icon aria-hidden="true"></ion-icon>`,
});
expect(root).toEqualHtml(`
<ion-icon class="md" role="img" aria-hidden="true">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
});

it('renders rtl with aria-hidden', async () => {
const { root } = await newSpecPage({
components: [Icon],
Expand All @@ -46,21 +32,6 @@ describe('icon', () => {
`);
});

it('renders default aria-label', async () => {
const { root } = await newSpecPage({
components: [Icon],
html: `<ion-icon name="chevron-forward"></ion-icon>`,
});

expect(root).toEqualHtml(`
<ion-icon class="md" name="chevron-forward" role="img" aria-label="chevron forward">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
});

it('renders custom aria-label', async () => {
const { root } = await newSpecPage({
components: [Icon],
Expand Down Expand Up @@ -105,34 +76,4 @@ describe('icon', () => {
</ion-icon>
`);
});

it('renders default label after changing source', async () => {
const page = await newSpecPage({
components: [Icon],
html: `<ion-icon name="chevron-forward"></ion-icon>`,
});

const icon = page.root;

expect(icon).toEqualHtml(`
<ion-icon class="md" name="chevron-forward" role="img" aria-label="chevron forward">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);

if (icon) {
icon.name = 'trash';
}
await page.waitForChanges();

expect(icon).toEqualHtml(`
<ion-icon class="md" name="trash" role="img" aria-label="trash">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
});
});

0 comments on commit e358a4f

Please sign in to comment.