@@ -252,6 +252,60 @@ suite('Styling', () => {
252252 assert . equal ( getComputedStyleValue ( div ! , 'border-top-width' ) . trim ( ) , '10px' ) ;
253253 } ) ;
254254
255+ test . only ( '@apply renders in nested elements when sub-element renders separately first' , async ( ) => {
256+ class I extends LitElement {
257+ render ( ) { return html `
258+ < style >
259+ : host {
260+ dis play: block;
261+ width: 100px;
262+ height: 100px;
263+ bor der: 2px solid black;
264+ margin- to p: 10px;
265+ @apply --bag;
266+ }
267+ </ style > Hi` ;
268+ }
269+ }
270+ customElements . define ( 'x-applied' , I ) ;
271+
272+ const name = generateElementName ( ) ;
273+ class E extends LitElement {
274+ applied : HTMLElement | undefined ;
275+
276+ render ( ) { return html `
277+ < style >
278+ : host {
279+ - - bag: {
280+ bor der: 10px solid black;
281+ margin- to p: 2px;
282+ }
283+ }
284+ </ style >
285+ < x-applied > </ x-applied > ` ;
286+ }
287+
288+ firstUpdated ( ) {
289+ this . applied = this . shadowRoot ! . querySelector ( 'x-applied' ) as LitElement ;
290+ }
291+ }
292+ customElements . define ( name , E ) ;
293+
294+ const firstApplied = document . createElement ( 'x-applied' ) as I ;
295+ container . appendChild ( firstApplied ) ;
296+ const el = document . createElement ( name ) as E ;
297+ container . appendChild ( el ) ;
298+
299+ // Workaround for Safari 9 Promise timing bugs.
300+ await firstApplied . updateComplete && el . updateComplete && await ( el . applied as I ) ! . updateComplete ;
301+
302+ await nextFrame ( ) ;
303+ assert . equal ( getComputedStyleValue ( firstApplied ! , 'border-top-width' ) . trim ( ) , '2px' ) ;
304+ assert . equal ( getComputedStyleValue ( firstApplied ! , 'margin-top' ) . trim ( ) , '10px' ) ;
305+ assert . equal ( getComputedStyleValue ( el . applied ! , 'border-top-width' ) . trim ( ) , '10px' ) ;
306+ assert . equal ( getComputedStyleValue ( el . applied ! , 'margin-top' ) . trim ( ) , '2px' ) ;
307+ } ) ;
308+
255309} ) ;
256310
257311suite ( 'ShadyDOM' , ( ) => {
0 commit comments