0

I have a web part that works for every browser but not in IE.

enter image description here

It seems to have troubles with "startsWith" which is a function that is not supported in IE11, fair enough. But when I changed the code for a one that is supported by IE11, I still get the same error. Only places where I could find non-supported functions for IE11 is in the temporary .js files. I have tried a gulp clean and run but it doesn't work. How can I make my code compatible/compiled to IE11 friendly code?

0

You can polyfill String.prototype.startsWith() with the following snippet:

if (!String.prototype.startsWith) {
    Object.defineProperty(String.prototype, 'startsWith', {
        value: function(search, pos) {
            pos = !pos || pos < 0 ? 0 : +pos;
            return this.substring(pos, pos + search.length) === search;
        }
    });
}

For SharePoint SPFx web part, you can install polyfill using command below.

npm install --save @pnp/polyfill-ie11

Refer to: Polyfill

  • Did this fix the issue? I personally experienced the error because of having a polyfill, it seems startsWith is already being implemented by default SharePoint Online JS since very recently – Cameron Verhelst May 7 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.