Luke Scott (2015-02-06T19:38:06.000Z)
d at domenic.me (2015-02-17T18:13:31.875Z)
The following should be sufficient with the current ES6, spec, right? It currently works in 6to5. ```js function mixin(classObject, …traits) { var newClassObject = class extends classObject{} // … fill in prototype here } ``` Below is a possible workaround for pre-ES6 code (without being transpired), provided that an Object.isClass is added (checks for internal classConstructor flag), which would always return false in pollyfills. ```js function mixin(classObject, traits) { var newClassObject; if (Object.isClass(classObject)) { newClassObject = eval("class extends classObject{}"); } else { newClassObject = function() {classObject.apply(this, arguments);}; newClassObject.prototype = Object.create(classObject.prototype); newClassObject.prototype.constructor = newClassObject; } // … fill in prototype here } ``` It’s an ugly hack. Unfortunately the eval is necessary because Chrome throws “Unexpected reserved word” for the class keyword.
d at domenic.me (2015-02-17T18:13:20.628Z)
The following should be sufficient with the current ES6, spec, right? It currently works in 6to5. ```js function mixin(classObject, …traits) { var newClassObject = class extends classObject{} // … fill in prototype here } ``` Below is a possible workaround for pre-ES6 code (without being transpired), provided that an Object.isClass is added (checks for internal classConstructor flag), which would always return false in pollyfills. ```js function mixin(classObject, traits) { var newClassObject; if (Object.isClass(classObject)) { newClassObject = eval("class extends classObject{}”); } else { newClassObject = function() {classObject.apply(this, arguments);}; newClassObject.prototype = Object.create(classObject.prototype); newClassObject.prototype.constructor = newClassObject; } // … fill in prototype here } ``` It’s an ugly hack. Unfortunately the eval is necessary because Chrome throws “Unexpected reserved word” for the class keyword.