vminpoly icon indicating copy to clipboard operation
vminpoly copied to clipboard

Tokenizer breaks IE 8 and older - Quick fix

Open oddpixel opened this issue 9 years ago • 1 comments

This plugin seems to break on IE 8 and older because Array.filter is not supported and will give you an error.

https://github.com/saabi/vminpoly/blob/master/tokenizer.js#L501

A quick way to fix this yourself is to include the following snippet:

if (!Array.prototype.filter)
{
  Array.prototype.filter = function(fun /*, thisp */)
  {
    "use strict";

    if (this === void 0 || this === null)
      throw new TypeError();

    var t = Object(this);
    var len = t.length >>> 0;
    if (typeof fun !== "function")
      throw new TypeError();

    var res = [];
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in t)
      {
        var val = t[i]; // in case fun mutates this
        if (fun.call(thisp, val, i, t))
          res.push(val);
      }
    }

    return res;
  };
}

oddpixel avatar Dec 18 '15 23:12 oddpixel

I cannot seem to reproduce the error you are having with native IE 8.0.7601.17514 on a Windows 7 Ultimate 64 SP1 box. Just checked the demo and everything works 100% spot on here. Not checked on lower or higher versions IE but 8.0.7601.17514 works fine from looking at the demo and resizing the viewport.

ghost avatar Mar 12 '16 22:03 ghost