paulmillr / es6-shim

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

Set constructor does not follow spec #282

Closed ide closed 10 years ago

ide commented 10 years ago

Based on my reading of https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-objects and looking at Safari 8 / iOS 8's behavior, Set(...) and new Set(...) should behave differently. Specifically. Set(...) called as a function optionally takes an iterable while new Set(...) called as a constructor takes variable arguments.

Safari 8 (10600.1.8) native Set implementation:

> a = [...new Set(1, 2, 3)]
[1, 2, 3]
> a = [...new Set([1, 2, 3])]
[Array[3]]
domenic commented 10 years ago

Safari 8 is wrong. Per spec Set(...) should throw, and new Set(...) should take an iterable.

ide commented 10 years ago

OK, that looks right to me after re-reading the spec. Will open a bug on the WebKit side...