feat(csr): diagnose missing output binding functions
This commit is contained in:
@@ -210,6 +210,17 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
// CustomEvent can be unavailable in minimal DOM test environments.
|
||||
}
|
||||
}
|
||||
|
||||
function warnMissingBindingFunction(statement, resolve, element) {
|
||||
var match = /^\s*([A-Za-z_$][\w$]*)\s*\(/.exec(statement || "");
|
||||
if (!match || typeof resolve(match[1]) === "function") return;
|
||||
warnOnce(
|
||||
"WRN-DEV-BINDING-MISSING",
|
||||
"Component binding calls '" + match[1] + "', but that function does not exist in the parent scope.",
|
||||
element,
|
||||
{ binding: statement, functionName: match[1] },
|
||||
);
|
||||
}
|
||||
/*__WRNEXUS_DEV_END__*/
|
||||
|
||||
function scheduleUpdateHook(element, callback) {
|
||||
@@ -2514,6 +2525,9 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
locals.event = undefined;
|
||||
locals.$event = undefined;
|
||||
try {
|
||||
/*__WRNEXUS_DEV_START__*/
|
||||
warnMissingBindingFunction(outStmt, function (name) { return peekScope(name); }, componentRoot);
|
||||
/*__WRNEXUS_DEV_END__*/
|
||||
return runStmt(outStmt, locals);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
|
||||
Reference in New Issue
Block a user