r83934 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83933‎ | r83934 | r83935 >
Date:18:04, 14 March 2011
Author:catrope
Status:ok
Tags:
Comment:
Followup r83891: don't insert a newline before ++ or -- . Patch by Paul Copperman
Modified paths:
  • /trunk/phase3/includes/libs/JavaScriptMinifier.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/libs/JavaScriptMinifierTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/libs/JavaScriptMinifierTest.php
@@ -71,6 +71,9 @@
7272 // Division vs. regex nastiness
7373 array( "alert( (10+10) / '/'.charCodeAt( 0 ) + '//' );", "alert((10+10)/'/'.charCodeAt(0)+'//');" ),
7474 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);" ),
7578 );
7679 }
7780
Index: trunk/phase3/includes/libs/JavaScriptMinifier.php
@@ -526,10 +526,11 @@
527527 $state = self::STATEMENT;
528528 $lineLength = 0;
529529 } elseif( $maxLineLength > 0 && $lineLength + $end - $pos > $maxLineLength &&
530 - !isset( $semicolon[$state][$type] ) )
 530+ !isset( $semicolon[$state][$type] ) && $type !== self::TYPE_INCR_OP )
531531 {
532532 // 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.
534535 $out .= "\n";
535536 $lineLength = 0;
536537 // Check, whether we have to separate the token from the last one with whitespace

Follow-up revisions

RevisionCommit summaryAuthorDate
r846281.17wmf1: MFT r83934 to unbreak the minifiercatrope19:37, 23 March 2011
r85434MFT: r83885, r83891, r83897, r83902, r83903, r83934, r83965, r83979, r83988, ...demon13:38, 5 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83891Followup r83885: implement maximum line length and statement termination (eac...catrope13:24, 14 March 2011

Status & tagging log