Permalink
Browse files

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.
  • Loading branch information...
1 parent 2960272 commit 2db7490db5a0efde738c58c920e002b28a34234c @glasser glasser committed May 21, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 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.

0 comments on commit 2db7490

Please sign in to comment.