@@ -13,8 +13,8 @@ import {
13
13
ARIAProperty ,
14
14
ariaPropertyToAttribute ,
15
15
isAriaAttribute ,
16
+ polyfillARIAMixin ,
16
17
polyfillElementInternalsAria ,
17
- setupHostAria ,
18
18
} from './aria.js' ;
19
19
20
20
describe ( 'aria' , ( ) => {
@@ -52,79 +52,40 @@ describe('aria', () => {
52
52
} ) ;
53
53
} ) ;
54
54
55
- describe ( 'setupHostAria ()' , ( ) => {
55
+ describe ( 'polyfillARIAMixin ()' , ( ) => {
56
56
@customElement ( 'test-setup-aria-host' )
57
57
class TestElement extends LitElement {
58
58
static {
59
- setupHostAria ( TestElement ) ;
59
+ polyfillARIAMixin ( TestElement ) ;
60
60
}
61
61
62
62
override render ( ) {
63
63
return html `< slot > </ slot > ` ;
64
64
}
65
65
}
66
66
67
- it ( 'should not hydrate tabindex attribute on creation' , ( ) => {
67
+ it ( 'should reflect ARIAMixin properties to attributes' , async ( ) => {
68
68
const element = new TestElement ( ) ;
69
- expect ( element . hasAttribute ( 'tabindex' ) )
70
- . withContext ( 'has tabindex attribute' )
71
- . toBeFalse ( ) ;
72
- } ) ;
73
-
74
- it ( 'should set tabindex="0" on element once connected' , ( ) => {
75
- const element = new TestElement ( ) ;
76
- document . body . appendChild ( element ) ;
77
- expect ( element . getAttribute ( 'tabindex' ) )
78
- . withContext ( 'tabindex attribute value' )
79
- . toEqual ( '0' ) ;
80
-
81
- element . remove ( ) ;
82
- } ) ;
83
-
84
- it ( 'should not set tabindex on connected if one already exists' , ( ) => {
85
- const element = new TestElement ( ) ;
86
- element . tabIndex = - 1 ;
87
69
document . body . appendChild ( element ) ;
88
- expect ( element . getAttribute ( 'tabindex' ) )
89
- . withContext ( 'tabindex attribute value' )
90
- . toEqual ( '-1' ) ;
91
-
70
+ element . role = 'button' ;
71
+ element . ariaLabel = 'Foo' ;
72
+ await element . updateComplete ;
73
+ expect ( element . getAttribute ( 'role' ) )
74
+ . withContext ( 'role attribute value' )
75
+ . toEqual ( 'button' ) ;
76
+
77
+ expect ( element . getAttribute ( 'aria-label' ) )
78
+ . withContext ( 'aria-label attribute value' )
79
+ . toEqual ( 'Foo' ) ;
92
80
element . remove ( ) ;
93
81
} ) ;
94
-
95
- it ( 'should not change tabindex if disconnected and reconnected' , ( ) => {
96
- const element = new TestElement ( ) ;
97
- document . body . appendChild ( element ) ;
98
- element . tabIndex = - 1 ;
99
- element . remove ( ) ;
100
- document . body . appendChild ( element ) ;
101
- expect ( element . getAttribute ( 'tabindex' ) )
102
- . withContext ( 'tabindex attribute value' )
103
- . toEqual ( '-1' ) ;
104
- } ) ;
105
-
106
- if ( ! ( 'role' in Element . prototype ) ) {
107
- describe ( 'polyfill' , ( ) => {
108
- it ( 'should hydrate aria attributes when ARIAMixin is not supported' , async ( ) => {
109
- const element = new TestElement ( ) ;
110
- document . body . appendChild ( element ) ;
111
- element . role = 'button' ;
112
- await element . updateComplete ;
113
- expect ( element . getAttribute ( 'role' ) )
114
- . withContext ( 'role attribute value' )
115
- . toEqual ( 'button' ) ;
116
-
117
- element . remove ( ) ;
118
- } ) ;
119
- } ) ;
120
- }
121
82
} ) ;
122
83
123
84
describe ( 'polyfillElementInternalsAria()' , ( ) => {
124
85
@customElement ( 'test-polyfill-element-internals-aria' )
125
86
class TestElement extends LitElement {
126
87
static {
127
- setupHostAria ( TestElement ) ;
88
+ polyfillARIAMixin ( TestElement ) ;
128
89
}
129
90
130
91
internals = polyfillElementInternalsAria ( this , this . attachInternals ( ) ) ;
0 commit comments