paulmillr / es6-shim

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

Question: How well will es6-shim do if V8 shipped Symbol.species, but not for Arrays? #398

Closed littledan closed 8 years ago

littledan commented 8 years ago

If V8 shipped the Symbol.species property on different objects in different releases, would ES6-shim be able to cope well with that, or would it get tripped up, imagining that the 'species' property on Symbol implied that Arrays had all of the logic in their methods?

ljharb commented 8 years ago

Typically, engines only ship a well-known symbol when it's fully implemented. es6-shim does have an internal addDefaultSpecies method which won't be tripped up by some of them existing and some not - but I don't think we currently do runtime tests for all of the relevant methods - so we'd probably have to add a bunch of those checks to patch all the methods v8 hadn't gotten to yet.

What's the advantage of shipping it piecemeal?

littledan commented 8 years ago

Shipping it piecemeal might get parts of it sooner. Arrays are a bit more complicated to ship for performance reasons. If you think it'll break existing deployments if it's shipped piecemeal, then that's a decent argument for delaying shipping until the symbols is fully implemented.

ljharb commented 8 years ago

It's really hard for me to estimate since I haven't dug into the species stuff yet.

In general, I don't think any well-known symbol (even iterator) is a good idea to enable unless all parts of it are there. Could the species stuff go behind a flag until it's all ready?

littledan commented 8 years ago

Sure, it'll just be unavailable to users for longer then. In general, ES2015 is only partly done, and we're shipping it piecemeal. But if this should go as a package, then that's that.

ljharb commented 8 years ago

Closing for now, please let me know if there are further questions/updates.