Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alvarosg88 opened this issue Mar 17, 2017 · 1 comment
Closed

Comments

@alvarosg88
Copy link

alvarosg88 commented Mar 17, 2017

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!

@Haroenv
Copy link
Owner

Haroenv commented Mar 17, 2017

Cool, I'll link this issue in the section on the bottom of the readme about support! Thanks for figuring it out!

@Haroenv Haroenv closed this as completed Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants