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

IE11 support / Object.assign() #104

Open
raygit83 opened this issue May 8, 2019 · 1 comment
Open

IE11 support / Object.assign() #104

raygit83 opened this issue May 8, 2019 · 1 comment

Comments

@raygit83
Copy link

raygit83 commented May 8, 2019

Any chance to see an IE11 patch which apparently doesn't support Object.assign() ?

Thanks.

@raygit83
Copy link
Author

raygit83 commented May 9, 2019

Here are the changes required to facilitate IE11 support:

  1. Add a polyfill for Object.assign(), e.g. right before this.init() on the bottom of CMS.js:

"function"!=typeof Object.assign&&(Object.assign=function(n,t){"use strict";if(null==n)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(n),e=1;e<arguments.length;e++){var o=arguments[e];if(null!=o)for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&(r[c]=o[c])}return r});

The ES5 polyfills pulled in via the example pages' html do not include a Object.assign() implementation btw.

  1. Use a different means to trigger a hashchange event in this.init():

Replace

window.dispatchEvent(new HashChangeEvent('hashchange'));

by the following snippet

try {
  window.dispatchEvent(new HashChangeEvent('hashchange'));
}
catch(e) {
  window.location.hash = window.location.hash;
}

In IE new HashChangeEvent results in "Undefined property: HashChangeEvent." and window.location.hash = window.location.hash; won't trigger a hashchange event in e.g. Chrome, so keeping the old code in a try block seems to be a good idea.

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

1 participant