paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

IE11 - Object doesn't support property or method 'bind' #409

Closed OClement closed 8 years ago

OClement commented 8 years ago

Line 30 of es6-shim.js: var _apply = Function.call.bind(function.apply)

Triggers Object doesn't support property or method 'bind' in IE11

ljharb commented 8 years ago

Are you loading anything else in the page at the time? Function.call === Function.prototype.call and is a function, so it should definitely have .bind.

ljharb commented 8 years ago

Also, are you loading anything else before es5-shim and es6-shim?

Could you create a jsfiddle that repros?

OClement commented 8 years ago

All the scripts loaded, in that order:

  <script src="scripts/system.js"></script>
  <script src="scripts/es6-promise.js"></script>
  <script src="scripts/es6-shim.js"></script>
  <script src="scripts/Reflect.js"></script>
  <script src="scripts/Rx.js"></script>
  <script src="scripts/angular2-polyfills.js"></script>
  <script src="scripts/angular2.dev.js"></script>
  <script src="scripts/http.dev.js"></script>
  <script src="scripts/router.dev.js"></script>
  <script src="scripts/lodash.js"></script>

Are you saying Ie11 also need es5-shim ? Sorry I haven't had to support IE in a long time :)

Will try this out and see if I can create a fiddle or plunkr soon Problem is I don't have IE11 handy at the moment

Thanks

ljharb commented 8 years ago

A few things - es6-promise and Reflect are redundant if you have the es6-shim. Second, System.js must load after es6-shim. If you change the loading order, is it fixed? Third, es5-shim is always required for every browser because none exist that fully comply with ES5, even latest Chrome. Load that before es6-shim.

OClement commented 8 years ago

Wow ok, I'll need to review all this Thanks a lot for the info! I'll give this all a try ASAP and come back with results

OClement commented 8 years ago

Sorry for the delay

So you were definitely right, by adding es5 then es6 shims resolved the issue

Thanks for your help, closing

ljharb commented 8 years ago

@OClement fwiw I'd still be interested in fixing this, if you could prepare a fiddle with system.js before es6-shim.js and verify that it breaks in IE 11, I can use that to repro :-)

OClement commented 8 years ago

I'm not exactly sure to understand what there is to fix; I am under the impression the issue was on my side where I was not loading es5-shims before the es6 ones, leading to IE not working properly;

Are you saying this isn't intended?

ljharb commented 8 years ago

@OClement it's kind of both. Shims should be loaded first, which fixed your issue. However, I like my libraries to be robust even when they're not used correctly - so I'd prefer the shim to work as well as possible even when not loaded first. IE 11 has a native "bind", so the es5-shim shouldn't be required - the implication is that system.js is somehow breaking the native "bind" method.

OClement commented 8 years ago

Ok I see; I'll check if I can find some time to create a fiddle or plunk or something, but I am tight on time unfortunately, so don't expect one real quick

I am starting to wonder if the core of this issue is not actually IE's compatibility view mode As you probably know already, all "sites" of an Intranet are displayed using Compatibility View mode by default, which almost replicates an IE8 environment (this missing Function.prototype.bind and the likes)

Naturally, when my QA tried IE11 with Es6 shims alone, it was still missing that method on the Function prototype because of that; I then added Es5 shims, which fixed this particular issue but we ran into something else (I can't quite recall what was the error). Applying different fixes (mainly for the stack I am using which involves Angular2 and SystemJs), it was working fine in Edge but still not in IE11, which is when I thought about this compatibility mode issue; Disabling this mode made it work right away

Long story short, I am wondering if it would have worked right out with only es6-shims and compatibility mode off...

ljharb commented 8 years ago

aha, yes, that's possible. Compatibility view mode does break a lot of things (many of which es5-shim and es6-shim patch, when both loaded).

Thanks, I'll take a look but I'm much less concerned about supporting compatibility view mode.

OClement commented 8 years ago

I agree I don't really see need We pretty much have to instruct our clients they need to disable this whenever they want to use IE anyway, this thing's a scourge, for lack of a better word