mirror of
https://github.com/matthiasmullie/minify.git
synced 2025-02-22 12:33:33 +01:00
Fix issue #394
This commit is contained in:
parent
acaee1b7ca
commit
b3458006ef
@ -429,6 +429,12 @@ class JS extends Minify
|
||||
$content = preg_replace('/(for\([^;\{]*;[^;\{]*;[^;\{]*(\{([^\{\}]*(?-2))*[^\{\}]*\})?[^;\{]*\));(\}|$)/s', '\\1;;\\4', $content);
|
||||
|
||||
$content = preg_replace('/(for\([^;\{]+\s+in\s+[^;\{]+\));(\}|$)/s', '\\1;;\\2', $content);
|
||||
|
||||
/*
|
||||
* Do the same for the if's that don't have a body but are followed by ;}
|
||||
*/
|
||||
$content = preg_replace('/(\bif\s*\([^{;]*\));\}/s', '\\1;;}', $content);
|
||||
|
||||
/*
|
||||
* Below will also keep `;` after a `do{}while();` along with `while();`
|
||||
* While these could be stripped after do-while, detecting this
|
||||
|
@ -1321,6 +1321,16 @@ var largeScreen=2048',
|
||||
'if(l!==3){for(var V=w.length;l<V;V+=w.map(function(e){if(e>5){return e-5}return e}).length);}else var C=3'
|
||||
);
|
||||
|
||||
// https://github.com/matthiasmullie/minify/issues/394
|
||||
$tests[] = array(
|
||||
'var a = function(){var b; if(b=3);}',
|
||||
'var a=function(){var b;if(b=3);}',
|
||||
);
|
||||
$tests[] = array(
|
||||
'jQuery(document).ready(function(e){ if (jQuery(document.body).on("updated_wc_div", o), jQuery(document.body).on("updated_cart_totals", o)); });',
|
||||
'jQuery(document).ready(function(e){if(jQuery(document.body).on("updated_wc_div",o),jQuery(document.body).on("updated_cart_totals",o));})',
|
||||
);
|
||||
|
||||
// known minified files to help doublecheck changes in places not yet
|
||||
// anticipated in these tests
|
||||
$files = glob(__DIR__.'/sample/minified/*.js');
|
||||
|
Loading…
x
Reference in New Issue
Block a user