Skip to content

Object.assign() & String.prototype.includes() not working on IE11 #90

Description

@alvarosg88

Hi guys!

I recently had a problem running a webapp in IE11 which includes holmes. IE doesn't recognize some ES6 methods and properties of your source code and it was blocking part of my own js.

Errors come when IE is trying to recognize Object.assign() and String.prototype.includes()

I tried to add the polyfills included in the MDN documentation at the start of your source code. And it works! Now holmes.js runs fine in IE11 with this hack:

if (typeof Object.assign != 'function') {
  Object.assign = function (target, varArgs) {
    'use strict';
    if (target == null) {
      throw new TypeError('Cannot convert undefined or null to object');
    }

    var to = Object(target);

    for (var index = 1; index < arguments.length; index++) {
      var nextSource = arguments[index];

      if (nextSource != null) {
        for (var nextKey in nextSource) {
          if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
            to[nextKey] = nextSource[nextKey];
          }
        }
      }
    }
    return to;
  };
}

if (!String.prototype.includes) {
    String.prototype.includes = function() {
        'use strict';
        return String.prototype.indexOf.apply(this, arguments) !== -1;
    };
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes

I hope you can find this fix useful for adding it in a future upgrade :)

Regards!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions