Is it possible to pass a class expression as parameter?
Have not tried the eval
route yet..
// CardtsElements.Zone contains a valid class expression
// used to create a valid Zone Custom Element
let extend = (source, name, definitionClassExpression) =>
customElements.define('CARDTS-' + name,
class extends CardtsElements[source] definitionClassExpression);
^^^^SYNTAX ERROR^^^^^^^^^^
// Create a new 'CARDTS-FOUNDATION' element extending 'CARDTS-ZONE'
extend('Zone','Foundation', {
static get observedAttributes() {
return ['suit','draggable','drop'];
}
constructor(){}
});
You can pass your class expression as a class factory function:
function
,superclass
): theclass
you want to extend,class
.