complete framework remediation validation
This commit is contained in:
@@ -174,7 +174,7 @@ export function browserModuleRequired(ast: PageAst): boolean {
|
||||
return functions.length > 0 || selectedBrowserImports(ast, functions).length > 0;
|
||||
}
|
||||
|
||||
function functionEntry(
|
||||
function _functionEntry(
|
||||
ast: PageAst,
|
||||
fn: RuntimeFunctionDecl,
|
||||
availableFunctions: string[],
|
||||
@@ -242,7 +242,10 @@ function functionEntry(
|
||||
.join(" ");
|
||||
const peerAliases = !stateNames.length
|
||||
? functionAliases
|
||||
.map((name) => `const ${name} = (...__wrnexusPeerArgs) => context.functions[${JSON.stringify(name)}](...__wrnexusPeerArgs);`)
|
||||
.map(
|
||||
(name) =>
|
||||
`const ${name} = (...__wrnexusPeerArgs) => context.functions[${JSON.stringify(name)}](...__wrnexusPeerArgs);`,
|
||||
)
|
||||
.join("\n")
|
||||
: `const __wrnexusFlush = () => { ${syncStateToContext} };
|
||||
const __wrnexusRestore = () => { ${syncStateFromContext} };
|
||||
@@ -271,9 +274,15 @@ function functionEntry(
|
||||
const commitBinding = stateNames.length
|
||||
? `const __wrnexusCommit = () => { ${copyBack} };
|
||||
${!parameterNames.has("commit") && !declaredLocals.has("commit") && !functionAliases.includes("commit") ? "const commit = __wrnexusCommit;" : ""}
|
||||
${!parameterNames.has("setTimeout") && !declaredLocals.has("setTimeout") && !functionAliases.includes("setTimeout") ? `const setTimeout = (callback, delay, ...args) => globalThis.setTimeout(() => {
|
||||
${
|
||||
!parameterNames.has("setTimeout") &&
|
||||
!declaredLocals.has("setTimeout") &&
|
||||
!functionAliases.includes("setTimeout")
|
||||
? `const setTimeout = (callback, delay, ...args) => globalThis.setTimeout(() => {
|
||||
try { return callback(...args); } finally { __wrnexusCommit(); }
|
||||
}, delay);` : ""}`
|
||||
}, delay);`
|
||||
: ""
|
||||
}`
|
||||
: "";
|
||||
const body = eraseFunctionTypes(fn.body);
|
||||
const runtimeBindings = [
|
||||
@@ -312,10 +321,7 @@ export function generateBrowserModule(ast: PageAst): string {
|
||||
const sharedProps = ast.props
|
||||
.map((entry) => entry.name)
|
||||
.filter(
|
||||
(name) =>
|
||||
safeIdentifier(name) &&
|
||||
!RUNTIME_BINDINGS.has(name) &&
|
||||
!sharedState.includes(name),
|
||||
(name) => safeIdentifier(name) && !RUNTIME_BINDINGS.has(name) && !sharedState.includes(name),
|
||||
);
|
||||
const callableAliases = functionNames.filter(
|
||||
(name) =>
|
||||
@@ -362,9 +368,13 @@ function __wrnexusCreateClientFunctions(context) {
|
||||
const __wrnexusCommit = () => { ${sharedCommit} };
|
||||
const __wrnexusRestore = () => { ${sharedRestore} };
|
||||
${!hasAuthoredCommit ? "const commit = __wrnexusCommit;" : ""}
|
||||
${!hasAuthoredSetTimeout ? `const setTimeout = (callback, delay, ...args) => globalThis.setTimeout(() => {
|
||||
${
|
||||
!hasAuthoredSetTimeout
|
||||
? `const setTimeout = (callback, delay, ...args) => globalThis.setTimeout(() => {
|
||||
try { return callback(...args); } finally { __wrnexusCommit(); }
|
||||
}, delay);` : ""}
|
||||
}, delay);`
|
||||
: ""
|
||||
}
|
||||
const implementations = {
|
||||
${implementations}
|
||||
};
|
||||
|
||||
@@ -752,8 +752,7 @@ function renderNestedComponentInvocation(
|
||||
|
||||
if (
|
||||
!attr.value.includes("{") ||
|
||||
(!exprRefsState(attr.value, ctx.stateNames) &&
|
||||
!exprRefsState(attr.value, ctx.propNames))
|
||||
(!exprRefsState(attr.value, ctx.stateNames) && !exprRefsState(attr.value, ctx.propNames))
|
||||
) {
|
||||
return rendered;
|
||||
}
|
||||
|
||||
@@ -328,9 +328,7 @@ test("stateful component keeps both prop and state text reactive", async () => {
|
||||
const out = render({ start: "10", label: "Score" });
|
||||
expect(out).toContain('data-scope="start: 10, label: "Score", count: 10"');
|
||||
expect(out).toContain('data-on-click="count++"');
|
||||
expect(out).toContain(
|
||||
'<span data-text="label">Score</span>: <span data-text="count">10</span>',
|
||||
);
|
||||
expect(out).toContain('<span data-text="label">Score</span>: <span data-text="count">10</span>');
|
||||
|
||||
expect(out).toContain('data-scope="');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user