I tried to run the bundle of MVC4 on javascript files that contain the following function:
$.fn.ApplyBehavior = function (behaviors) {
var fns = behaviors.split(",");
var $t = $(this);
$.each(fns, function (i, o) {
try {
var callfn = eval(o);
if (typeof callfn == 'function') {
callfn.call($t);
}
} catch (e) {
// faill silently
console.log(o);
console.log(e.stack);
}
});
return this;
}
the produced result from the bundle looks like this:
$.fn.ApplyBehavior = function(n) {
var t = n.split(","), i = $(this);
return $.each(t, function(i, o) {
try {
var callfn = eval(o);
typeof callfn == "function" && callfn.call(i)
} catch (e) {
console.log(o), console.log(e.stack)
}
}), this
},
The problem appears from the use of "i" in the output result, I already use "i" inside the "each" loop, so obviously the clash is in calling a function with "i" as the context
I am using the lastest NuGet package of optimization (1.1.0-Beta1), and the usual Bundle code:
bundle = new ScriptBundle("~/scripts/uijs").Include("~/js/ui.web.js");
bundles.Add(bundle);
Am I doing anything wrong? Why isn't it pre-detecting the use of "i"? If this is a bug, how do I report it?