-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Alexandre Morgaut edited this page Mar 3, 2017
·
2 revisions
Welcome to the babel-plugin-transform-class wiki!
Here few hints about this babel transform-class
plugin
The most simple way to get the polyfills your target platform potentially needs with this plugin is probably to use Polyfill.io:
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Object.create,Object.assign"></script>
But if your prefer to fully control your polyfills, here some resources
The minimum support of Object.create() as used by this plugin can be simply achieved via this little snippet:
if (!Object.create) {
Object.create = function (prototype) {
function F() {}
F.prototype = prototype;
return new F();
}
}
or this variant using the previously non official but widely supported __proto__
property:
if (!Object.create) {
Object.create = function (prototype) {
return {__proto__: prototype};
}
}
See also
- A little gist with minimum support of the 2nd argument
- A faster Object.create polyfill that reuses F (doesn't support the 2nd argument to Object.create)
- The more complete MDN Object.create() polyfill. It uses
Object.defineProperties()
for which ES3 platforms need a Polyfill so here the one proposed by MDN. - Object.create() on Polyfill.io
Here a very minimum Object.assign() polyfill as used by this plugin (with only 2 arguments support & no return value)
if (!Object.assign) {
Object.assign = function(target, properties) {
for (var key in properties) target[key] = properties[key];
};
}
- The more complete MDN Object.assign() polyfill (with better error handling & more).
- Object.assign() on Polyfill.io