@@ -183,8 +183,15 @@ export function restoreHasGsapScript(html: string): boolean {
183183}
184184
185185// The active document is the whole preview; a sub-composition lives in each host that inlines it.
186- function liveScopes ( doc : Document , path : string , isActive : boolean ) : ParentNode [ ] {
186+ // Only the active document's GSAP script can be re-run in place.
187+ function liveScopes (
188+ doc : Document ,
189+ path : string ,
190+ isActive : boolean ,
191+ file : UndoRestoreFile ,
192+ ) : ParentNode [ ] {
187193 if ( isActive ) return [ doc ] ;
194+ if ( restoreHasGsapScript ( file . previous ) || restoreHasGsapScript ( file . restored ) ) return [ ] ;
188195 return Array . from ( doc . querySelectorAll ( `[data-composition-file="${ CSS . escape ( path ) } "]` ) ) ;
189196}
190197
@@ -210,11 +217,10 @@ function fileTargets(
210217 doc : Document ,
211218 path : string ,
212219 isActive : boolean ,
213- { previous , restored } : UndoRestoreFile ,
220+ file : UndoRestoreFile ,
214221) : RestoreTarget [ ] | null {
215- // Only the active document's GSAP script can be re-run in place.
216- if ( ! isActive && ( restoreHasGsapScript ( previous ) || restoreHasGsapScript ( restored ) ) ) return null ;
217- const scopes = liveScopes ( doc , path , isActive ) ;
222+ const { previous, restored } = file ;
223+ const scopes = liveScopes ( doc , path , isActive , file ) ;
218224 const diff = diffSoftReloadableRestore ( previous , restored ) ;
219225 if ( ! scopes . length || ! diff || hasAmbiguousGsapScriptChange ( previous , restored ) ) return null ;
220226 const restoredByKey = identityElementMap ( parseRestoreSource ( restored ) ) ;
0 commit comments