Index: trunk/phase3/tests/phpunit/includes/libs/JavaScriptMinifierTest.php |
— | — | @@ -71,6 +71,9 @@ |
72 | 72 | // Division vs. regex nastiness |
73 | 73 | array( "alert( (10+10) / '/'.charCodeAt( 0 ) + '//' );", "alert((10+10)/'/'.charCodeAt(0)+'//');" ), |
74 | 74 | array( "if(1)/a /g.exec('Pa ss');", "if(1)/a /g.exec('Pa ss');" ), |
| 75 | + |
| 76 | + // newline insertion after 1000 chars: break after the "++", not before |
| 77 | + array( str_repeat( ';', 996 ) . "if(x++);", str_repeat( ';', 996 ) . "if(x++\n);" ), |
75 | 78 | ); |
76 | 79 | } |
77 | 80 | |
Index: trunk/phase3/includes/libs/JavaScriptMinifier.php |
— | — | @@ -526,10 +526,11 @@ |
527 | 527 | $state = self::STATEMENT; |
528 | 528 | $lineLength = 0; |
529 | 529 | } elseif( $maxLineLength > 0 && $lineLength + $end - $pos > $maxLineLength && |
530 | | - !isset( $semicolon[$state][$type] ) ) |
| 530 | + !isset( $semicolon[$state][$type] ) && $type !== self::TYPE_INCR_OP ) |
531 | 531 | { |
532 | 532 | // This line would get too long if we added $token, so add a newline first. |
533 | | - // Only do this if it won't trigger semicolon insertion though. |
| 533 | + // Only do this if it won't trigger semicolon insertion and if it won't |
| 534 | + // put a postfix increment operator on its own line, which is illegal in js. |
534 | 535 | $out .= "\n"; |
535 | 536 | $lineLength = 0; |
536 | 537 | // Check, whether we have to separate the token from the last one with whitespace |