@@ -1714,6 +1714,39 @@ const tl = gsap.timeline({ paused: true });
17141714 expect ( html . indexOf ( 'tl.set("#card"' ) ) . toBeGreaterThan ( declaration ) ;
17151715 } ) ;
17161716
1717+ it ( "a first animation in a sub-composition file lands inside its template" , async ( ) => {
1718+ const projectDir = createProjectDir ( ) ;
1719+ const app = new Hono ( ) ;
1720+ registerFileRoutes ( app , createAdapter ( projectDir ) ) ;
1721+ const sub =
1722+ '<template id="sub-template"><div data-composition-id="sub"><div id="card"></div></div></template>\n' ;
1723+ mkdirSync ( join ( projectDir , "compositions" ) , { recursive : true } ) ;
1724+ writeHtml ( projectDir , "compositions/sub.html" , sub ) ;
1725+
1726+ const res = await app . request (
1727+ "http://localhost/projects/demo/gsap-mutations/compositions/sub.html" ,
1728+ {
1729+ method : "POST" ,
1730+ headers : { "Content-Type" : "application/json" } ,
1731+ body : JSON . stringify ( {
1732+ type : "add" ,
1733+ targetSelector : "#card" ,
1734+ method : "to" ,
1735+ position : 0 ,
1736+ properties : { opacity : 0 } ,
1737+ } ) ,
1738+ } ,
1739+ ) ;
1740+
1741+ expect ( res . status ) . toBe ( 200 ) ;
1742+ const html = readFileSync ( join ( projectDir , "compositions/sub.html" ) , "utf-8" ) ;
1743+ const close = html . indexOf ( "</template>" ) ;
1744+ expect ( html . indexOf ( 'window.__timelines["sub"]' ) ) . toBeGreaterThan ( - 1 ) ;
1745+ expect ( html . lastIndexOf ( "<script" ) ) . toBeLessThan ( close ) ;
1746+ expect ( html . slice ( close ) . trim ( ) ) . toBe ( "</template>" ) ;
1747+ expect ( html ) . not . toContain ( "<body" ) ;
1748+ } ) ;
1749+
17171750 it ( "consolidate-position-writes leaves exactly one position write per selector" , async ( ) => {
17181751 const projectDir = createProjectDir ( ) ;
17191752 const CORRUPTED = `<!DOCTYPE html><html><body><script data-hyperframes-gsap>
0 commit comments