@@ -149,6 +149,34 @@ describe('Basic', function() {
149149 expect ( isUnfocusable ( shadowButton ) ) . to . equal ( true ) ;
150150 } ) ;
151151
152+ it ( 'should apply to elements added to shadow trees later in time' , function ( done ) {
153+ host . inert = true ;
154+ const shadowButton = document . createElement ( 'button' ) ;
155+ shadowButton . textContent = 'Shadow button' ;
156+ host . shadowRoot . appendChild ( shadowButton ) ;
157+ // Give time to mutation observers.
158+ setTimeout ( function ( ) {
159+ expect ( isUnfocusable ( shadowButton ) ) . to . equal ( true ) ;
160+ done ( ) ;
161+ } ) ;
162+ } ) ;
163+
164+ it ( 'should apply to elements that create shadow tree later in time' , function ( done ) {
165+ fixture . removeChild ( host ) ;
166+ host = document . createElement ( 'div' ) ;
167+ fixture . appendChild ( host ) ;
168+ host . inert = true ;
169+ const shadowRoot = host . createShadowRoot ( ) ;
170+ const shadowButton = document . createElement ( 'button' ) ;
171+ shadowButton . textContent = 'Shadow button' ;
172+ shadowRoot . appendChild ( shadowButton ) ;
173+ // Give time to mutation observers.
174+ setTimeout ( function ( ) {
175+ expect ( isUnfocusable ( shadowButton ) ) . to . equal ( true ) ;
176+ done ( ) ;
177+ } ) ;
178+ } ) ;
179+
152180 it ( 'should apply inert styles inside shadow trees' , function ( ) {
153181 const shadowButton = document . createElement ( 'button' ) ;
154182 shadowButton . textContent = 'Shadow button' ;
@@ -196,6 +224,36 @@ describe('Basic', function() {
196224 expect ( isUnfocusable ( shadowButton ) ) . to . equal ( true ) ;
197225 } ) ;
198226
227+ it ( 'should apply to elements added to shadow trees later in time' , function ( done ) {
228+ host . inert = true ;
229+ const shadowButton = document . createElement ( 'button' ) ;
230+ shadowButton . textContent = 'Shadow button' ;
231+ host . shadowRoot . appendChild ( shadowButton ) ;
232+ // Give time to mutation observers.
233+ setTimeout ( function ( ) {
234+ expect ( isUnfocusable ( shadowButton ) ) . to . equal ( true ) ;
235+ done ( ) ;
236+ } ) ;
237+ } ) ;
238+
239+ it ( 'should apply to elements that create shadow tree later in time' , function ( done ) {
240+ fixture . removeChild ( host ) ;
241+ host = document . createElement ( 'div' ) ;
242+ fixture . appendChild ( host ) ;
243+ host . inert = true ;
244+ const shadowRoot = host . attachShadow ( {
245+ mode : 'open'
246+ } ) ;
247+ const shadowButton = document . createElement ( 'button' ) ;
248+ shadowButton . textContent = 'Shadow button' ;
249+ shadowRoot . appendChild ( shadowButton ) ;
250+ // Give time to mutation observers.
251+ setTimeout ( function ( ) {
252+ expect ( isUnfocusable ( shadowButton ) ) . to . equal ( true ) ;
253+ done ( ) ;
254+ } ) ;
255+ } ) ;
256+
199257 it ( 'should apply inert styles inside shadow trees' , function ( ) {
200258 const shadowButton = document . createElement ( 'button' ) ;
201259 shadowButton . textContent = 'Shadow button' ;
0 commit comments