Skip to content

Commit

Permalink
close #101: [4.x] Compiled bundle is broken after minification.
Browse files Browse the repository at this point in the history
  • Loading branch information
veged committed Nov 2, 2015
1 parent 4b9b4c9 commit c0aa4f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/bemhtml/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ BEMHTML.prototype.compile = function compile(code) {
BEMHTML.prototype.recompileInput = function recompileInput(code) {
var out = code.toString();

var args = BEMHTML.locals.join(', ');
var args = BEMHTML.locals;
if (typeof code === 'function') {
var start = out.match(/^function([^{]+){/);
var start = out.match(/^function\s*\(([^{]+)\)\s*{/);

// Reuse function if it already has right arguments
if (start !== null && start[1].indexOf('(' + args + ')') !== -1)
if (start !== null && start[1].split(/,\s*/).length === args.length)
return code;
}

// Strip the function
out = out.replace(/^function[^{]+{|}$/g, '');

// And recompile it with right arguments
out = new Function(args, out);
out = new Function(args.join(', '), out);

return out;
};
Expand Down

0 comments on commit c0aa4f9

Please sign in to comment.