2
Vote

Can't have 'break' outside of loop

description

I get the following error during minify:
(Minifier) Can't have 'break' outside of loop: break t
But that is possible in javascript.

Se the following example from http://www.w3schools.com/jsref/jsref_break.asp:
Using the break statement with a label reference, to "jump out" of a JavaScript code block:
var cars = ["BMW", "Volvo", "Saab", "Ford"];
var text = "";
list: {
text += cars[0] + "\n";
text += cars[1] + "\n";
text += cars[2] + "\n";
break list;
text += cars[3] + "\n";
}
The result of text will be:
BMW
Volvo
Saab

comments

Technobuddha wrote Mar 18, 2016 at 7:13 PM

CKEditor uses this construct, and breaks the minification

acordero wrote Jun 9, 2016 at 7:53 AM

I'm having this same error in an actual for loop, though the line marked with the error is in a containing function (not even the closest one). Using "Bundler & Minifier" version 1.9.157. Can't share the code, but it is something like this:

return angularService.methodReturningPromise() .then(function () { jquerylist.each(function (i, w) { promiseslist.push(new Promise( function (fulfill, reject) { for (var i in pw) { if (some_condition) { some_action; break; } } })) }) });