mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(item): inherit aria attributes before render (#26546)
Resolves #26538
This commit is contained in:
@@ -226,9 +226,12 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
|
||||
}
|
||||
}
|
||||
|
||||
componentWillLoad() {
|
||||
this.inheritedAriaAttributes = inheritAttributes(this.el, ['aria-label']);
|
||||
}
|
||||
|
||||
componentDidLoad() {
|
||||
raf(() => {
|
||||
this.inheritedAriaAttributes = inheritAttributes(this.el, ['aria-label']);
|
||||
this.setMultipleInputs();
|
||||
this.focusable = this.isFocusable();
|
||||
});
|
||||
|
||||
@@ -12,4 +12,17 @@ test.describe('item: axe', () => {
|
||||
.analyze();
|
||||
expect(results.violations).toEqual([]);
|
||||
});
|
||||
|
||||
test('should reflect aria-label', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-item id="item-1" aria-label="test"></ion-item>
|
||||
<ion-item id="item-2" aria-label="test" button="true"></ion-item>
|
||||
`);
|
||||
|
||||
const item1 = await page.locator('#item-1 .item-native');
|
||||
const item2 = await page.locator('#item-2 .item-native');
|
||||
|
||||
expect(await item1.getAttribute('aria-label')).toEqual('test');
|
||||
expect(await item2.getAttribute('aria-label')).toEqual('test');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user