@@ -198,6 +198,80 @@ describe('aria', () => {
198198 element . remove ( ) ;
199199 } ) ;
200200
201+ it ( 'should not override aria attributes on host when set before connection' ,
202+ async ( ) => {
203+ const element = new TestElement ( ) ;
204+ element . setAttribute ( 'aria-label' , 'Value set by user' ) ;
205+ element . internals . ariaLabel = 'Value set on internals' ;
206+ document . body . appendChild ( element ) ;
207+ await element . updateComplete ;
208+ expect ( element . getAttribute ( 'aria-label' ) )
209+ . withContext ( 'aria-label attribute value on host' )
210+ . toEqual ( 'Value set by user' ) ;
211+ expect ( element . internals . ariaLabel )
212+ . withContext ( 'ariaLabel internals property still the same' )
213+ . toEqual ( 'Value set on internals' ) ;
214+
215+ element . remove ( ) ;
216+ } ) ;
217+
218+ it ( 'should not override aria properties on host when set before connection' ,
219+ async ( ) => {
220+ const element = new TestElement ( ) ;
221+ element . ariaLabel = 'Value set by user' ;
222+ element . internals . ariaLabel = 'Value set on internals' ;
223+ document . body . appendChild ( element ) ;
224+ await element . updateComplete ;
225+ expect ( element . getAttribute ( 'aria-label' ) )
226+ . withContext ( 'aria-label attribute value on host' )
227+ . toEqual ( 'Value set by user' ) ;
228+ expect ( element . ariaLabel )
229+ . withContext ( 'ariaLabel property value on host' )
230+ . toEqual ( 'Value set by user' ) ;
231+ expect ( element . internals . ariaLabel )
232+ . withContext ( 'ariaLabel internals property still the same' )
233+ . toEqual ( 'Value set on internals' ) ;
234+
235+ element . remove ( ) ;
236+ } ) ;
237+
238+ it ( 'should not override role attribute on host when set before connection' ,
239+ async ( ) => {
240+ const element = new TestElement ( ) ;
241+ element . setAttribute ( 'role' , 'Value set by user' ) ;
242+ element . internals . role = 'Value set on internals' ;
243+ document . body . appendChild ( element ) ;
244+ await element . updateComplete ;
245+ expect ( element . getAttribute ( 'role' ) )
246+ . withContext ( 'role attribute value on host' )
247+ . toEqual ( 'Value set by user' ) ;
248+ expect ( element . internals . role )
249+ . withContext ( 'role internals property still the same' )
250+ . toEqual ( 'Value set on internals' ) ;
251+
252+ element . remove ( ) ;
253+ } ) ;
254+
255+ it ( 'should not override role property on host when set before connection' ,
256+ async ( ) => {
257+ const element = new TestElement ( ) ;
258+ element . role = 'Value set by user' ;
259+ element . internals . role = 'Value set on internals' ;
260+ document . body . appendChild ( element ) ;
261+ await element . updateComplete ;
262+ expect ( element . getAttribute ( 'role' ) )
263+ . withContext ( 'role attribute value on host' )
264+ . toEqual ( 'Value set by user' ) ;
265+ expect ( element . role )
266+ . withContext ( 'role property value on host' )
267+ . toEqual ( 'Value set by user' ) ;
268+ expect ( element . internals . role )
269+ . withContext ( 'role internals property still the same' )
270+ . toEqual ( 'Value set on internals' ) ;
271+
272+ element . remove ( ) ;
273+ } ) ;
274+
201275 it ( 'should handle setting role multiple times before connection' ,
202276 async ( ) => {
203277 const element = new TestElement ( ) ;
@@ -216,6 +290,25 @@ describe('aria', () => {
216290 element . remove ( ) ;
217291 } ) ;
218292
293+ it ( 'should handle setting role multiple times before connection when property is set on host' ,
294+ async ( ) => {
295+ const element = new TestElement ( ) ;
296+ element . role = 'radio' ;
297+ element . internals . role = 'button' ;
298+ element . internals . role = 'checkbox' ;
299+
300+ expect ( element . internals . role )
301+ . withContext ( 'internals.role before connection' )
302+ . toEqual ( 'checkbox' ) ;
303+ document . body . appendChild ( element ) ;
304+ await element . updateComplete ;
305+ expect ( element . internals . role )
306+ . withContext ( 'internals.role after connection' )
307+ . toEqual ( 'checkbox' ) ;
308+
309+ element . remove ( ) ;
310+ } ) ;
311+
219312 it ( 'should handle setting aria properties multiple times before connection' ,
220313 async ( ) => {
221314 const element = new TestElement ( ) ;
@@ -234,6 +327,25 @@ describe('aria', () => {
234327 element . remove ( ) ;
235328 } ) ;
236329
330+ it ( 'should handle setting aria properties multiple times before connection when property is set on host' ,
331+ async ( ) => {
332+ const element = new TestElement ( ) ;
333+ element . ariaLabel = 'First' ;
334+ element . internals . ariaLabel = 'First' ;
335+ element . internals . ariaLabel = 'Second' ;
336+
337+ expect ( element . internals . ariaLabel )
338+ . withContext ( 'internals.ariaLabel before connection' )
339+ . toEqual ( 'Second' ) ;
340+ document . body . appendChild ( element ) ;
341+ await element . updateComplete ;
342+ expect ( element . internals . ariaLabel )
343+ . withContext ( 'internals.ariaLabel after connection' )
344+ . toEqual ( 'Second' ) ;
345+
346+ element . remove ( ) ;
347+ } ) ;
348+
237349 it ( 'should handle setting role after first connection while disconnected' ,
238350 async ( ) => {
239351 const element = new TestElement ( ) ;
0 commit comments