Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beautifying bracket-less if/elses #838

Closed
benstock85 opened this issue Jan 7, 2016 · 1 comment
Closed

Beautifying bracket-less if/elses #838

benstock85 opened this issue Jan 7, 2016 · 1 comment
Milestone

Comments

@benstock85
Copy link

I am using jsbeautify to beautify a large number of documents (in a proxy) and found a tiny bug. The following code triggers the issue:

function(url, callback) {
    var script = document.createElement("script")
    if (true) script.onreadystatechange = function() {
        /* dummy */
    }
    else script.onload = callback;
}

This will be re-written to:

function(url, callback) {
    var script = document.createElement("script")
    if (true) script.onreadystatechange = function() {
        /* dummy */
    } else script.onload = callback;
}

which in turn is a syntax error. There must either be a line break after the } or a semi-colon.

@bitwiseman
Copy link
Member

Thanks for the clear description.
Wow, that is ... quite an edge case. 😄
I'll see what what I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants