mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(core): revert Function constructor back to inline IIFE for composition scripts
The Function constructor (3bb0d1ef) breaks sub-composition scripts that
call document.getElementById() — the constructor creates functions with
global scope, losing access to the composition-scoped DOM proxy. Native
method calls on proxy-returned elements throw "Illegal invocation".
Reverts to the inline IIFE that preserves the closure over __hfScoped*
variables. The original motivation (handling </script> in source) is
already handled by the compiler's script bundling path.
Closes #1074
This commit is contained in:
@@ -216,7 +216,6 @@ export function wrapScopedCompositionScript(
|
|||||||
const authoredRootIdFormsLiteral = JSON.stringify(
|
const authoredRootIdFormsLiteral = JSON.stringify(
|
||||||
getAuthoredRootIdSelectorForms(authoredRootId?.trim() || ""),
|
getAuthoredRootIdSelectorForms(authoredRootId?.trim() || ""),
|
||||||
);
|
);
|
||||||
const sourceLiteral = JSON.stringify(source);
|
|
||||||
return `(function(){
|
return `(function(){
|
||||||
var __hfCompId = ${compositionIdLiteral};
|
var __hfCompId = ${compositionIdLiteral};
|
||||||
var __hfTimelineCompId = ${timelineCompositionIdLiteral};
|
var __hfTimelineCompId = ${timelineCompositionIdLiteral};
|
||||||
@@ -486,8 +485,9 @@ export function wrapScopedCompositionScript(
|
|||||||
});
|
});
|
||||||
var __hfRun = function() {
|
var __hfRun = function() {
|
||||||
try {
|
try {
|
||||||
var __hfScript = Function("document", "gsap", "window", "__hyperframes", ${sourceLiteral});
|
(function(document, gsap, window, __hyperframes) {
|
||||||
__hfScript.call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
|
${source}
|
||||||
|
}).call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
console.error(__hfErrorLabel, __hfCompId, _err);
|
console.error(__hfErrorLabel, __hfCompId, _err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user