es-shims / es5-shim

ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines
MIT License
7.12k stars 899 forks source link

value.join is not a function #434

Closed binarykitchen closed 7 years ago

binarykitchen commented 7 years ago

I have require('es5-shim') at top of my JS entry file which is supposed to shim Array's join function.

But few lines further down, where I have require('angular') and AngularJS code gets executed, TypeError: value.join is not a function is thrown for this user agent useragent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0

Using the latest version here. But do not see why this is happening.

ljharb commented 7 years ago

Firefox 50 already has join on arrays, so the es5-shim should be a noop.

If you remove the es5-shim import, does it still happen?

Which version of angular are you using? I believe some versions of angular 1 have bugs around this sort of thing.

binarykitchen commented 7 years ago

haven't tried removing the shim yet as i dont want to break my site. using angular v1.6.3 here.

these are the contents of my main.js file

require('es5-shim')
require('angular')
require('angular-resource')
require('angular-local-storage')
require('angular-google-analytics')
require('angular-route')
require('angular-sanitize')
require('ng-email-list')

// some app code
...
ljharb commented 7 years ago

In Firefox 50 specifically, the es5-shim shouldn't be having much effect, so I think you should be able to remove it locally and test?

binarykitchen commented 7 years ago

well i can't reproduce this locally. only happens by random on my production site.

ljharb commented 7 years ago

Either way I think it's definitely an angular 1 bug, considering that arrays always have a join method (that's pre-ES3, es5-shim fixes it but doesn't provide it), and considering that's where the error is thrown from.

binarykitchen commented 7 years ago

hmm, i ll try to debug in the angularjs core code then ugh ...

ljharb commented 7 years ago

I'd also recommend searching their open and closed issues; it may have been previously reported.

Happy to reopen if it turns out to be a bug in es5-shim!