Ticket #4695: 4695.patch

File 4695.patch, 1.1 KB (added by Garry Yao, 14 years ago)
  • test/test.js

     
    267267
    268268                [       "if(a){if(B)doB();}else if(c)doC();" ],
    269269
     270                [       "if(a){for(;;){if(B){doB();}}}else{doC();}",
     271                        "if(a)for(;;){if(B)doB();}else doC();"
     272                ],
    270273        ];
    271274
    272275        var tests =
  • _source/includes/scriptcompressor.js

     
    623623
    624624                                var hasCurly = ( !block || !block.getFirstChild() || !!block.getFirstChild().getNext() );
    625625
     626                                // Avoid single enclosed 'if...elseif' block combines with any 'else/elseif'
     627                                // statement following the loop. (#4695)
     628                                // E.g. if()for(){if()elseif()}else AND ..elseif()for(){if()}else
     629                                if( !hasCurly )
     630                                {
     631                                        try
     632                                        {
     633                                                block.getFirstChild().getFirstChild().getType() == Token.IFNE && ( hasCurly = 1 );
     634                                        }
     635                                        catch( er ){}
     636                                }
     637
    626638                                if ( hasCurly )
    627639                                        out( '{' );
    628640
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy