diff --git a/Resources/Private/Php/JavaScriptMinifier.php b/Resources/Private/Php/JavaScriptMinifier.php index 0b4be9a..2268487 100644 --- a/Resources/Private/Php/JavaScriptMinifier.php +++ b/Resources/Private/Php/JavaScriptMinifier.php @@ -1,4 +1,5 @@ true ) ); - + // Rules for when newlines should be inserted if // $statementsOnOwnLine is enabled. // $newlineBefore is checked before switching state, @@ -514,7 +515,7 @@ public static function minify( $s, $statementsOnOwnLine = false, $maxLineLength return self::parseError($s, $end, 'Number with several E' ); } $end++; - + // + sign is optional; - sign is required. $end += strspn( $s, '-+', $end ); $len = strspn( $s, '0123456789', $end ); @@ -564,13 +565,21 @@ public static function minify( $s, $statementsOnOwnLine = false, $maxLineLength $out .= ' '; $lineLength++; } - + if ( + $type === self::TYPE_LITERAL + && ( $token === 'true' || $token === 'false' ) + && ( $state === self::EXPRESSION || $state === self::PROPERTY_EXPRESSION ) + && $last !== '.' + ) { + $token = ( $token === 'true' ) ? '!0' : '!1'; + } + $out .= $token; $lineLength += $end - $pos; // += strlen( $token ) $last = $s[$end - 1]; $pos = $end; $newlineFound = false; - + // Output a newline after the token if required // This is checked before AND after switching state $newlineAdded = false; @@ -589,7 +598,7 @@ public static function minify( $s, $statementsOnOwnLine = false, $maxLineLength } elseif( isset( $goto[$state][$type] ) ) { $state = $goto[$state][$type]; } - + // Check for newline insertion again if ( $statementsOnOwnLine && !$newlineAdded && isset( $newlineAfter[$state][$type] ) ) { $out .= "\n"; @@ -598,9 +607,9 @@ public static function minify( $s, $statementsOnOwnLine = false, $maxLineLength } return $out; } - + static function parseError($fullJavascript, $position, $errorMsg) { // TODO: Handle the error: trigger_error, throw exception, return false... return false; } -} +} \ No newline at end of file