@@ -4,6 +4,7 @@ import { config } from '../../global/config';
4
4
import { getIonMode } from '../../global/ionic-global' ;
5
5
import { AnimationBuilder , Color } from '../../interface' ;
6
6
import { ButtonInterface } from '../../utils/element-interface' ;
7
+ import { inheritAttributes } from '../../utils/helpers' ;
7
8
import { createColorClasses , hostContext , openURL } from '../../utils/theme' ;
8
9
9
10
/**
@@ -22,6 +23,7 @@ import { createColorClasses, hostContext, openURL } from '../../utils/theme';
22
23
shadow : true
23
24
} )
24
25
export class BackButton implements ComponentInterface , ButtonInterface {
26
+ private inheritedAttributes : { [ k : string ] : any } = { } ;
25
27
26
28
@Element ( ) el ! : HTMLElement ;
27
29
@@ -64,6 +66,8 @@ export class BackButton implements ComponentInterface, ButtonInterface {
64
66
@Prop ( ) routerAnimation : AnimationBuilder | undefined ;
65
67
66
68
componentWillLoad ( ) {
69
+ this . inheritedAttributes = inheritAttributes ( this . el , [ 'aria-label' ] ) ;
70
+
67
71
if ( this . defaultHref === undefined ) {
68
72
this . defaultHref = config . get ( 'backButtonDefaultHref' ) ;
69
73
}
@@ -115,9 +119,10 @@ export class BackButton implements ComponentInterface, ButtonInterface {
115
119
}
116
120
117
121
render ( ) {
118
- const { color, defaultHref, disabled, type, hasIconOnly, backButtonIcon, backButtonText } = this ;
122
+ const { color, defaultHref, disabled, type, hasIconOnly, backButtonIcon, backButtonText, inheritedAttributes } = this ;
119
123
const showBackButton = defaultHref !== undefined ;
120
124
const mode = getIonMode ( this ) ;
125
+ const ariaLabel = inheritedAttributes [ 'aria-label' ] || backButtonText || 'back' ;
121
126
122
127
return (
123
128
< Host
@@ -139,7 +144,7 @@ export class BackButton implements ComponentInterface, ButtonInterface {
139
144
disabled = { disabled }
140
145
class = "button-native"
141
146
part = "native"
142
- aria-label = { backButtonText || 'back' }
147
+ aria-label = { ariaLabel }
143
148
>
144
149
< span class = "button-inner" >
145
150
{ backButtonIcon && < ion-icon part = "icon" icon = { backButtonIcon } aria-hidden = "true" lazy = { false } > </ ion-icon > }
0 commit comments