marko
Version:
Optimized runtime for Marko templates.
39 lines (38 loc) • 1.38 kB
JavaScript
;
const require_control_flow = require("../dom-CiFITSPN.js");
//#region src/dom/catch.feat.ts
const handlePendingTry = (fn, scope, branch) => {
while (branch) {
if (branch["#AwaitCounter"]?.i) return (branch[require_control_flow.PendingEffects] ||= []).push(fn, scope);
branch = branch[require_control_flow.ParentBranch];
}
};
require_control_flow.installCatch((runEffects) => (effects, checkPending = require_control_flow.placeholderShown.has(effects)) => {
if (checkPending || require_control_flow.caughtError.has(effects)) {
let i = 0;
let fn;
let scope;
let branch;
for (; i < effects.length;) {
fn = effects[i++];
scope = effects[i++];
if ((branch = scope["#ClosestBranch"])?.["#Gen"] !== 0 && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
}
} else runEffects(effects);
}, (runRender) => (render) => {
try {
let branch = render[require_control_flow.Scope][require_control_flow.ClosestBranch];
while (branch) {
if (branch["#PendingRenders"]) {
render[require_control_flow.Pending] = 1;
return branch[require_control_flow.PendingRenders].push(render);
}
branch = branch[require_control_flow.ParentBranch];
}
render[require_control_flow.Pending] = 0;
runRender(render);
} catch (error) {
require_control_flow.renderCatch(render[require_control_flow.Scope], error);
}
});
//#endregion