-
Notifications
You must be signed in to change notification settings - Fork 583
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
Safari forOf and spread issues for Set object. #1810
Comments
yeah, iterator protocol in JSC is still a work in progress. last I checked (in jan/feb), maybe it would make sense to always use the polyfilled version for JSC? |
We should probably be a lot stricter when it comes to determining when to use the polyfills. One suggestion is to use the polyfills if there is no |
I just ran into a similar issue with Safari on iOS 8.1.3. The problematic cases in my case were for-of over an Array as well as construction of a Map from an Array (or iterable). The specific reasons were that
I can work around the problems by including the following as the first script of the page: // Remove insufficient built-in implementations so that the polyfills from traceur-runtime kick in.
if (Array.prototype.entries && typeof [1].entries().next !== 'function') {
delete Array.prototype.entries;
}
if (Array.prototype.keys && typeof [1].keys().next !== 'function') {
delete Array.prototype.keys;
}
try {
new Map([]);
}
catch(e) {
delete Map;
} I assume these checks could be built into the polyfillArray and polyfillMap functions but have not tried that. |
WHAT!! How do you iterate over them then? How can they ship something so broken... makes me very sad. @cwalther What does Map.length return in Safari? If it says 0 we should be able to use that instead of using the try/catch. |
I have no idea what the purpose of these iterators is, they appear to have no methods (or other properties) at all besides the ones inherited from Object.
Interestingly, |
Sad. So misleading. Set throws when called. https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-iterable Step 1 |
I just see in that document that By the way, es6-shim also fixes the issues I had on that version of Safari, and it has a whole bunch of criteria for checking whether to replace Map, maybe that’s a more reliable source. (I didn’t use es6-shim as a final solution because I was wary of potential unintended interactions between es6-shim and traceur-runtime.) |
You are correct. Map.length should be 0. I think a suitable test is to see if Map.prototype[Symbol.iterator] is a function. |
Safari does not support ES6 Map/Set correctly which leads to trouble. Be more strict in detecting whether the native Map/Set is good enough. Fixes google#1650, google#1810
Safari does not support ES6 Map/Set correctly which leads to trouble. Be more strict in detecting whether the native Map/Set is good enough. Fixes google#1650, google#1810
When using the Set object, the following code fails in Safari 8 desktop and mobile:
"Error: undefined is not a function (evaluating 'f.next()')"
Note: This code fails to compile in the Traceur REPL on Safari.
https://google.github.io/traceur-compiler/demo/repl.html#var%20set%20%3D%20new%20Set(%5B1%2C2%2C3%2C4%5D)%3B%0A%0Avar%20arr%20%3D%20%5B...set%5D%3B%0A%0Afor%20(var%20v%20of%20set)%0A%20%20console.log(v)%3B%0A%0Avar%20vals%20%3D%20set.values()%3B%0Afor%20(var%20v%20of%20vals)%0A%20%20console.log(v)%3B%0A
The text was updated successfully, but these errors were encountered: