From 2db7490db5a0efde738c58c920e002b28a34234c Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 21 May 2014 16:19:43 -0700 Subject: [PATCH] Fix IE8 minification bug The minifier changed the two uses of HTMLTag into two different symbols: var n = function r() { var t = this instanceof e.Tag ? this : new r(), n = 0, o = arguments.length && arguments[0]; return o && "object" == typeof o && o.constructor === Object && (t.attrs = o, n++), n < arguments.length && (t.children = Array.prototype.slice.call(arguments, n)), t; }; return n.prototype = new e.Tag(), n.prototype.constructor = n, n.prototype.tagName = t, n; Then, IE8 apparently actually creates two separate objects for 'n' and 'r'; see #3 at http://kiro.me/blog/nfe_dilemma.html So just because n.prototype is an e.Tag doesn't make r.prototype a e.Tag This means that `new r() instanceof e.Tag` is false, and so the first line of the function leads to infinite recursion. I'm not sure if this is an uglify bug as well; dealing well with multiple declarations of the same function may be out of spec. Fixes #2037. --- packages/htmljs/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/htmljs/html.js b/packages/htmljs/html.js index f8348d6793..1b41d8e5a9 100644 --- a/packages/htmljs/html.js +++ b/packages/htmljs/html.js @@ -31,7 +31,7 @@ HTML.ensureTag = function (tagName) { // Given "p" create the function `HTML.P`. var makeTagConstructor = function (tagName) { // HTMLTag is the per-tagName constructor of a HTML.Tag subclass - var HTMLTag = function HTMLTag(/*arguments*/) { + var HTMLTag = function (/*arguments*/) { // Work with or without `new`. If not called with `new`, // perform instantiation by recursively calling this constructor. // We can't pass varargs, so pass no args.