question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using "default" in prop validation breaks YUI compressor

See original GitHub issue

Vue.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

  1. Make a component with validation
Vue.component('comp', {
    props: {
        foo: {
            type: String,
            default: 'a'
        },
        bar: {
            type: String,
            default: 'b'
        }
    }
}
  1. Paste it to YUI compressor http://ganquan.info/yui/

  2. 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:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
simplesmilercommented, Dec 2, 2016

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:

Vue.component('comp', {
    props: {
        foo: {
            type: String,
            'default': 'a',
        },
        bar: {
            type: String,
            'default': 'b',
        }
    }
})
0reactions
zsoltgrigorecommented, Dec 2, 2016

is a workaround for people

…and it is not even a workaround but a fully standard way to define objects in JS, just to be correct

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: Everything about Default Props | by Chidume Nnamdi
In this post, we'll learn all about default props in React. ... Its primary built to use the concept of Components for each...
Read more >
Prevent Default and Form Events - Beginner JavaScript
In this video, we are going to dive into the preventDefault() method that exists on the event (which you will likely use all...
Read more >
YUI Compressor - YUI Library
Defaults to stdout. ... The linebreak option is used in that case to split long lines after a specific column. It can also...
Read more >
Spring Boot Reference Documentation
Spring Security: Default Security Configuration, Auto-configuration for OAuth2, SAML ... Starter for using Java Bean Validation with Hibernate Validator.
Read more >
Java library for efficient CSS and JavaScript rendering / Sudo Null IT ...
The library fully supports YUI Compressorto minimize CSS / JavaScript and gzip ... breaks in output after the specified column number (-1 by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found