UNPKG

svgdom

Version:

Straightforward DOM implementation for SVG, HTML and XML

37 lines (27 loc) 955 B
export const extend = (...modules) => { var methods, key, i // Get object with extensions methods = modules.pop() for (i = modules.length - 1; i >= 0; i--) { for (key in methods) { modules[i].prototype[key] = methods[key] } } } export const extendStatic = (...modules) => { var methods, key, i // Get object with extensions methods = modules.pop() for (i = modules.length - 1; i >= 0; i--) { for (key in methods) { modules[i][key] = methods[key] } } } // TODO: refactor so that it takes a class export const mixin = (mixin, _class) => { const descriptors = Object.getOwnPropertyDescriptors(mixin) // const all = Object.getOwnPropertyNames(mixin) // const propNames = Object.keys(descriptors) // const methodNames = all.filter(p => !propNames.includes(p)) // for (const method of methodNames) { // _class.prototype[method] = mixin[method] // } Object.defineProperties(_class.prototype, descriptors) }