Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion core/src/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Component, ComponentInterface, Element, Host, Prop, h, writeTask } from '@stencil/core';

import { getIonMode } from '../../global/ionic-global';
import { inheritAttributes } from '../../utils/helpers';

import { cloneElement, createHeaderIndex, handleContentScroll, handleToolbarIntersection, setHeaderActive, setToolbarBackgroundOpacity } from './header.utils';

/**
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
*/
Expand All @@ -20,6 +22,7 @@ export class Header implements ComponentInterface {
private contentScrollCallback?: any;
private intersectionObserver?: any;
private collapsibleMainHeader?: HTMLElement;
private inheritedAttributes: { [k: string]: any } = {};

@Element() el!: HTMLElement;

Expand All @@ -41,6 +44,10 @@ export class Header implements ComponentInterface {
*/
@Prop() translucent = false;

componentWillLoad() {
this.inheritedAttributes = inheritAttributes(this.el, ['role']);
}

async componentDidLoad() {
await this.checkCollapsibleHeader();
}
Expand Down Expand Up @@ -143,9 +150,10 @@ export class Header implements ComponentInterface {
}

render() {
const { translucent } = this;
const { translucent, inheritedAttributes } = this;
const mode = getIonMode(this);
const collapse = this.collapse || 'none';

return (
<Host
role="banner"
Expand All @@ -159,6 +167,7 @@ export class Header implements ComponentInterface {
[`header-collapse-${collapse}`]: true,
[`header-translucent-${mode}`]: this.translucent,
}}
{...inheritedAttributes}
>
{ mode === 'ios' && translucent &&
<div class="header-background"></div>
Expand Down
11 changes: 11 additions & 0 deletions core/src/components/header/test/a11y/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { newE2EPage } from '@stencil/core/testing';
import { AxePuppeteer } from '@axe-core/puppeteer';

test('header: axe', async () => {
const page = await newE2EPage({
url: '/src/components/header/test/a11y?ionic:_testing=true'
});

const results = await new AxePuppeteer(page).analyze();
expect(results.violations.length).toEqual(0);
});
21 changes: 21 additions & 0 deletions core/src/components/header/test/a11y/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Header - a11y</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link href="../../../../../css/core.css" rel="stylesheet">
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
<script src="../../../../../scripts/testing/scripts.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
</head>

<body>
<ion-header></ion-header>
<main>
<h1>Headers</h1>
<ion-header role="none"></ion-header>
</main>
</body>
</html>