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

es6 and bootstrap 4.3.1 have issues on IE11 #164

Closed
lekoala opened this issue Mar 18, 2019 · 11 comments · Fixed by #193
Closed

es6 and bootstrap 4.3.1 have issues on IE11 #164

lekoala opened this issue Mar 18, 2019 · 11 comments · Fixed by #193
Labels
bug Something isn't working

Comments

@lekoala
Copy link

lekoala commented Mar 18, 2019

I've recently updated one of my website using polyfill.io to bootstrap 4.3.1 and now tooltips cause js error on IE11. The error goes away when removing polyfill.io or downgrading bootstrap to 4.3.0.

The issue seems linked to the "es6" bundle (if I only add es5, it works fine). Not sure which feature is causing the error, I'm still looking into it.

Bootstrap 4 issue for reference: twbs/bootstrap#28520

@lekoala lekoala changed the title es6 and bootstrap 4.3.1 have issues es6 and bootstrap 4.3.1 have issues on IE11 Mar 18, 2019
@JakeChampion JakeChampion transferred this issue from polyfillpolyfill/polyfill-service Mar 19, 2019
@lekoala
Copy link
Author

lekoala commented Mar 20, 2019

By the way, i didn't find an easy way to isolate which es6 polyfill is causing the issue, it would be great to be able to load polyfills one by one from the bundle in order to do that. So if the api could return all polyfills wrapped in functions you would have to call manually and expose somehow this list to the browser, it would help a lot. How would you proceed in order to know which one is causing the issue in the current setup ?

@JakeChampion JakeChampion added the bug Something isn't working label Apr 3, 2019
@JakeChampion
Copy link
Owner

@lekoala Could you please create a reproducible example on a service such as jsbin.com? Having something like that available helps us be able to debug and fix the issue :-)

@XhmikosR
Copy link

XhmikosR commented Apr 3, 2019

@JakeChampion: from the Bootstrap issue https://codepen.io/Johann-S/pen/zbaJPV

@XhmikosR
Copy link

XhmikosR commented Apr 3, 2019

Oops that doesn't have polyfill.io. Here's the updated one with polyfill.io and direct link since CodePen doesn't work on IE: https://s.codepen.io/XhmikosR/debug/NmGBmM

@lekoala
Copy link
Author

lekoala commented Apr 3, 2019

@XhmikosR thanks, thats the one! the pen is indeed breaking for me (and i guess anyone else in win 10 / ie 11)

@adamwinn
Copy link

adamwinn commented Apr 5, 2019

I have narrowed it down to the Array.from bundle that is causing this bug

twbs/bootstrap#28520

@adamwinn
Copy link

adamwinn commented Apr 5, 2019

The polyfill I'm using is https://cdn.polyfill.io/v3/polyfill.js?features=Object.assign,Array.from,Element.prototype.matches,Object.entries,Array.prototype.includes

Breaks:
https://cdn.polyfill.io/v3/polyfill.js?features=Object.assign,Array.from,Element.prototype.matches,Object.entries,Array.prototype.includes

Works:
https://cdn.polyfill.io/v3/polyfill.js?features=Object.assign,Element.prototype.matches,Object.entries,Array.prototype.includes

@EamonNerbonne
Copy link
Contributor

EamonNerbonne commented Apr 26, 2019

I've narrowed this down; this looks like a bug in the symbol polyfill.

Context:

twbs is checking object property types based on toString in the function toType, which contains this expression {}.toString.call(obj).

The bootstrap popover component is hoping for a function or null (the linked config is passed to the checker here), and it's receiving null. And indeed, when you call {}.toString.call(null). all browsers (AFAICT) return [object Null], which eventually would return the correct classification.

However, the symbol polyfill overwrites toString here, and it's that code that's getting called, rather than the IE11 native method (verified using the debugger).

That function contains the snippet toString(this) where toString is the original function, and this should be null. But this polyfill isn't in use strict mode! So that means that this is never null, but window. That's easy to verify, and it's by-spec, so not an IE11 bug.

  • (function (){ 'use strict'; return this; }).call(null) returns null: OK!
  • (function (){ return this; }).call(null) returns window: not OK.
  • and by extension (function() { 'use strict'; return (function (){ return this; }).call(null); })() also returns null.

So that means that either all polyfills should be in strict mode (no idea if that's realistic), or that at least the entire symbol polyfill should be in strict mode, or that at least the polyfilled toString should be in strict mode.

@EamonNerbonne
Copy link
Contributor

#193 would be a conservative fix.

@lekoala
Copy link
Author

lekoala commented Apr 26, 2019

@EamonNerbonne wow that's serious detective work there, thanks!

@EamonNerbonne
Copy link
Contributor

Thanks! It was a fun little dive ;-).

The temporary workaround I'm using until this is fixed is the following, by the way:

if (document.documentMode) {
    const origToString = Object.prototype.toString;
    Object.prototype.toString = function () {
        'use strict'; //only necessary if you're not already running everything in strict mode anyohw.
        if (this === null)
            return '[object Null]';
        return origToString.call(this);
    };
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
5 participants