1
1
import { Component , ComponentInterface , Element , Host , Prop , h , writeTask } from '@stencil/core' ;
2
2
3
3
import { getIonMode } from '../../global/ionic-global' ;
4
+ import { inheritAttributes } from '../../utils/helpers' ;
4
5
5
6
import { cloneElement , createHeaderIndex , handleContentScroll , handleToolbarIntersection , setHeaderActive , setToolbarBackgroundOpacity } from './header.utils' ;
7
+
6
8
/**
7
9
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
8
10
*/
@@ -20,6 +22,7 @@ export class Header implements ComponentInterface {
20
22
private contentScrollCallback ?: any ;
21
23
private intersectionObserver ?: any ;
22
24
private collapsibleMainHeader ?: HTMLElement ;
25
+ private inheritedAttributes : { [ k : string ] : any } = { } ;
23
26
24
27
@Element ( ) el ! : HTMLElement ;
25
28
@@ -41,6 +44,10 @@ export class Header implements ComponentInterface {
41
44
*/
42
45
@Prop ( ) translucent = false ;
43
46
47
+ componentWillLoad ( ) {
48
+ this . inheritedAttributes = inheritAttributes ( this . el , [ 'role' ] ) ;
49
+ }
50
+
44
51
async componentDidLoad ( ) {
45
52
await this . checkCollapsibleHeader ( ) ;
46
53
}
@@ -143,9 +150,10 @@ export class Header implements ComponentInterface {
143
150
}
144
151
145
152
render ( ) {
146
- const { translucent } = this ;
153
+ const { translucent, inheritedAttributes } = this ;
147
154
const mode = getIonMode ( this ) ;
148
155
const collapse = this . collapse || 'none' ;
156
+
149
157
return (
150
158
< Host
151
159
role = "banner"
@@ -159,6 +167,7 @@ export class Header implements ComponentInterface {
159
167
[ `header-collapse-${ collapse } ` ] : true ,
160
168
[ `header-translucent-${ mode } ` ] : this . translucent ,
161
169
} }
170
+ { ...inheritedAttributes }
162
171
>
163
172
{ mode === 'ios' && translucent &&
164
173
< div class = "header-background" > </ div >
0 commit comments