Skip to content

Cannot handle "in" operator within ternary statement? #60

@busticated

Description

@busticated

Hey there -

First, thanks so much for your work on Uglify / Uglify2 - such a wonderful tool. I ran into an error which I was able to trace back to a specific line in a jQuery plugin we use over here:

https://github.com/mathiasbynens/jquery-visibility/blob/master/jquery-visibility.js#L7

Specifically this part :

eventName = 'onfocusin' in document && 'hasFocus' in document ? 'focusin focusout' : 'focus blur',

It seems Uglify & Uglify2 doesn't like "in" operators within a ternary statement?

You can repro it pretty easily using your online demo tool thinger here:

http://lisperator.net/uglifyjs/#demo

Just copy and paste the jquery.visibility plugin src in, run uglify, and then copy & paste the output into chrome's js console.

Error is:

Uncaught SyntaxError: Unexpected token in 

To fix it, I just re-wrote the line as an if statement.

Anyway, hope it helps!
-matt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions