mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: better input validation for FunctionCall
This commit is contained in:
parent
c5fb6aa4fe
commit
530b8eb3ef
@ -10,10 +10,19 @@ class FunctionCall extends Node {
|
||||
|
||||
ok(this.callee, '"callee" is required');
|
||||
|
||||
this.args = def.args;
|
||||
let args = this.args = def.args;
|
||||
|
||||
if (this.args && !Array.isArray(this.args)) {
|
||||
throw new Error('Invalid args');
|
||||
if (args) {
|
||||
if (!Array.isArray(args)) {
|
||||
throw new Error('Invalid args');
|
||||
}
|
||||
|
||||
for (let i=0; i<args.length; i++) {
|
||||
let arg = args[i];
|
||||
if (!arg) {
|
||||
throw new Error('Arg ' + i + ' is not valid for function call: ' + JSON.stringify(this.toJSON(), null, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user