diff --git a/compiler/validate/js/propValidators/computed.js b/compiler/validate/js/propValidators/computed.js index 102ce73333..00b10af00d 100644 --- a/compiler/validate/js/propValidators/computed.js +++ b/compiler/validate/js/propValidators/computed.js @@ -21,7 +21,14 @@ export default function computed ( validator, prop ) { return; } - computation.value.params.forEach( param => { + const params = computation.value.params; + + if ( params.length === 0 ) { + validator.error( `A computed value must depend on at least one property`, computation.value.start ); + return; + } + + params.forEach( param => { const valid = param.type === 'Identifier' || param.type === 'AssignmentPattern' && param.left.type === 'Identifier'; if ( !valid ) { diff --git a/test/validator/computed-values/errors.json b/test/validator/computed-values/errors.json new file mode 100644 index 0000000000..3f4994e790 --- /dev/null +++ b/test/validator/computed-values/errors.json @@ -0,0 +1,8 @@ +[{ + "message": "A computed value must depend on at least one property", + "pos": 49, + "loc": { + "line": 4, + "column": 8 + } +}] \ No newline at end of file diff --git a/test/validator/computed-values/input.html b/test/validator/computed-values/input.html new file mode 100644 index 0000000000..92cb29d732 --- /dev/null +++ b/test/validator/computed-values/input.html @@ -0,0 +1,7 @@ +