Skip to content
This repository was archived by the owner on May 30, 2020. It is now read-only.
This repository was archived by the owner on May 30, 2020. It is now read-only.

Add invalid semicolon on multi-line for statements #47

@TiMESPLiNTER

Description

@TiMESPLiNTER

I tried to use the jsqueeze lib to compress my javascript in a Symfony framework application.

The library did something strange with this:

if ( !found ) {
    for ( found = [], elems = context.childNodes || context;
        ( elem = elems[ i ] ) != null;
        i++
    ) {
        // ...
    }
}

got squeezed into this:

if(!i){for(i=[],a=t.childNodes||t;(r=a[s])!=null;s++;){/*...*/}}

Firefox (v47.0) told me then: SyntaxError: missing ) after for-loop control
Chrome (v51.0.x) told me then: Uncaught SyntaxError: Unexpected token ;

In fact the the last semicolon is too much. When I change the compressed line to:

if(!i){for(i=[],a=t.childNodes||t;(r=a[s])!=null;s++){/*...*/}}

The squeezed javascript runs fine in both browsers.

(The line is from jQuery v1.12.4 (uncompressed, line 4557)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions