10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { html , LitElement , ReactiveController , TemplateResult } from 'lit' ;
14
13
import '@spectrum-web-components/progress-circle/sp-progress-circle.js' ;
14
+ import { html , LitElement , ReactiveController , TemplateResult } from 'lit' ;
15
15
16
16
/**
17
17
* Represents a host element with pending state.
@@ -58,7 +58,7 @@ export class PendingStateController<T extends HostWithPendingState>
58
58
id ="loader "
59
59
size ="s "
60
60
indeterminate
61
- aria-valuetext =${ pendingLabel }
61
+ aria-label =${ pendingLabel }
62
62
class ="progress-circle"
63
63
> </ sp-progress-circle >
64
64
`
@@ -73,15 +73,25 @@ export class PendingStateController<T extends HostWithPendingState>
73
73
const { pending, disabled, pendingLabel } = this . host ;
74
74
const currentAriaLabel = this . host . getAttribute ( 'aria-label' ) ;
75
75
76
+ function shouldCacheAriaLabel (
77
+ cached : string | null ,
78
+ current : string | null ,
79
+ pending : string | undefined
80
+ ) : string | boolean | null {
81
+ return (
82
+ ( ! cached && current && current !== pending ) ||
83
+ ( cached !== current && current && current !== pending )
84
+ ) ;
85
+ }
86
+
76
87
// If the current `aria-label` is different from the pending label, cache it
77
88
// or if the cached `aria-label` is different from the current `aria-label`, cache it
78
89
if (
79
- ( ! this . cachedAriaLabel &&
80
- currentAriaLabel &&
81
- currentAriaLabel !== pendingLabel ) ||
82
- ( this . cachedAriaLabel !== currentAriaLabel &&
83
- currentAriaLabel &&
84
- currentAriaLabel !== pendingLabel )
90
+ shouldCacheAriaLabel (
91
+ this . cachedAriaLabel ,
92
+ currentAriaLabel ,
93
+ pendingLabel
94
+ )
85
95
) {
86
96
this . cachedAriaLabel = currentAriaLabel ;
87
97
}
0 commit comments