@@ -3303,7 +3303,7 @@ ${["a", "b", "c", "d", "e", "f"].map((id, i) => ` <div data-composition-id="$
33033303 const eager = ( id : string ) =>
33043304 doc . querySelector ( `div[data-hf-scene="${ id } "]` ) ?. getAttribute ( "data-hf-scene-eager" ) ;
33053305 expect ( [ "a" , "b" , "c" , "d" , "e" , "f" ] . map ( eager ) ) . toEqual ( [
3306- null ,
3306+ "d reads it" ,
33073307 "its script uses window.__bSeq =" ,
33083308 "its script uses documentElement" ,
33093309 "its script names a" ,
@@ -3316,6 +3316,37 @@ ${["a", "b", "c", "d", "e", "f"].map((id, i) => ` <div data-composition-id="$
33163316 ) ;
33173317 } ) ;
33183318
3319+ it ( "keeps every scene an eager scene reads eager too, however far out it starts" , async ( ) => {
3320+ const scene = ( id : string , script : string ) =>
3321+ `<template id="${ id } -template"><div data-composition-id="${ id } "><p>${ id } </p>
3322+ <script>${ script } </script></div></template>` ;
3323+ const dir = makeTempProject ( {
3324+ "index.html" : `<!doctype html><html><head></head><body>
3325+ <div data-composition-id="main" data-width="1920" data-height="1080" data-duration="60">
3326+ <div data-composition-id="b" data-composition-src="compositions/b.html" data-start="30" data-duration="5"></div>
3327+ <div data-composition-id="a" data-composition-src="compositions/a.html" data-start="0" data-duration="5"></div>
3328+ <div data-composition-id="c" data-composition-src="compositions/c.html" data-start="40" data-duration="5"></div>
3329+ <div data-composition-id="d" data-composition-src="compositions/d.html" data-start="50" data-duration="5"></div>
3330+ </div></body></html>` ,
3331+ "compositions/b.html" : scene ( "b" , 'window.__timelines["b"] = window.__timelines["c"];' ) ,
3332+ "compositions/a.html" : scene (
3333+ "a" ,
3334+ 'document.title = String(Boolean(window.__timelines["b"]));' ,
3335+ ) ,
3336+ "compositions/c.html" : scene ( "c" , 'window.__timelines["c"] = gsap.timeline();' ) ,
3337+ "compositions/d.html" : scene ( "d" , 'window.__timelines["d"] = gsap.timeline();' ) ,
3338+ } ) ;
3339+ const doc = parseHTML ( await bundleToSingleHtml ( dir , { sceneParts : true } ) ) . document ;
3340+ const eager = ( id : string ) =>
3341+ doc . querySelector ( `div[data-hf-scene="${ id } "]` ) ?. getAttribute ( "data-hf-scene-eager" ) ;
3342+ expect ( [ "a" , "b" , "c" , "d" ] . map ( eager ) ) . toEqual ( [
3343+ "its script names b" ,
3344+ "its script names c" ,
3345+ "b reads it" ,
3346+ null ,
3347+ ] ) ;
3348+ } ) ;
3349+
33193350 it ( "marks a scene whose own script leaves work running as not swappable, and only that scene" , async ( ) => {
33203351 const dir = makeTempProject ( {
33213352 "index.html" : `<!doctype html><html><head>
0 commit comments