paulmillr / es6-shim

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

"e.delete is not a function" thrown when site is translated with Google Translate #438

Closed jsommr closed 7 years ago

jsommr commented 7 years ago

Following the translate link next to search results on Google will break js on any site using es6-shim. Examples:

http://translate.google.dk/translate?hl=da&sl=en&u=http://www.hostgator.com/ http://translate.google.dk/translate?hl=da&sl=en&u=http://www.videoadblocker.net/ http://translate.google.dk/translate?hl=da&sl=en&u=http://summit.presidents.eu/summit

This is because Google for some reason replaces "Set" with its own implementation.

Perhaps es6-shim could emit a warning instead of throwing exceptions? I don't think there's a way to get the original Set once it's replaced, except for creating an iframe and using its window object, but I don't know if that's a viable solution.

ljharb commented 7 years ago

This seems like a bug with Google Translate itself; one that would break any site using babel-polyfill/core-js as well. Have you filed it to Google?

ljharb commented 7 years ago

I think this is something I could special-case detect in es6-shim, though.

https://twitter.com/ljharb/status/849335573114363904 / http://translate.googleusercontent.com/translate_c?depth=2&hl=da&rurl=translate.google.com&sl=en&sp=nmt4&u=http://rawgit.com/es-shims/es6-shim/master/test/index.html&usg=ALkJrhiX_iY0sIXkR1g1IS9nwN_t5dyJ_A illustrates the problem as well.

jsommr commented 7 years ago

Haven't filed it to Google. Don't even know where to do that...

jsommr commented 7 years ago

core-js seems to work and also turns Set into its original function: http://translate.google.dk/translate?hl=da&sl=en&u=https://rawgit.com/zloirock/core-js/master/tests/tests.html

ljharb commented 7 years ago

@nerfpops that core-js test page seems to not actually be loading core-js.

ljharb commented 7 years ago

However, oddly, the core-js test page's Google JS code doesn't seem to be shimming Set either. Very strange.

ljharb commented 7 years ago

@nerfpops the next release of es6-shim will replace the broken Set shim with a compliant one on translated pages; I'm still not sure how the core-js test page was able to get at the native Set; but that can be fixed later.

jsommr commented 7 years ago

Awesome! You guys are fast :)