Using "default" in prop validation breaks YUI compressor
See original GitHub issueVue.js version
1.0.26
Reproduction Link
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/default The reserved word “default” must not be used in an object literal as property name!
Steps to reproduce
- Make a component with validation
Vue.component('comp', {
props: {
foo: {
type: String,
default: 'a'
},
bar: {
type: String,
default: 'b'
}
}
}
-
Paste it to YUI compressor http://ganquan.info/yui/
-
Compress
What is Expected?
Postprocessors using the produced code should not fail.
What is actually happening?
[ERROR] 5:20:invalid property id
[ERROR] 5:21:syntax error
[ERROR] 6:10:syntax error
[ERROR] 7:13:syntax error
[ERROR] 8:18:syntax error
[ERROR] 9:21:syntax error
[ERROR] 11:5:syntax error
[ERROR] 1:0:Compilation produced 7 syntax errors. org.mozilla.javascript.EvaluatorException: Compilation produced 7 syntax errors. at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:154) at org.mozilla.javascript.Parser.parse(Parser.java:392) at org.mozilla.javascript.Parser.parse(Parser.java:337) …
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
That’s a mistake on YUI compressor part. It’s only illegal to use keywords as identifiers, not as property names and accessors. Reference: MDN / Reserved word usage. If you have to deal with YUI compressor, you can quote the keywords:
…and it is not even a workaround but a fully standard way to define objects in JS, just to be correct