Destructure statics and includes from class properties (#8823)

This commit is contained in:
Jon Koops
2023-02-05 21:25:05 +01:00
committed by GitHub
parent d1016279f3
commit 25fc087617

View File

@ -10,7 +10,7 @@ import * as Util from './Util';
export function Class() {}
Class.extend = function (props) {
Class.extend = function ({statics, includes, ...props}) {
// @function extend(props: Object): Function
// [Extends the current class](#class-inheritance) given the properties to be included.
@ -43,19 +43,17 @@ Class.extend = function (props) {
}
// mix static properties into the class
if (props.statics) {
Util.extend(NewClass, props.statics);
if (statics) {
Util.extend(NewClass, statics);
}
// mix includes into the prototype
if (props.includes) {
Util.extend.apply(null, [proto].concat(props.includes));
if (includes) {
Util.extend.apply(null, [proto].concat(includes));
}
// mix given properties into the prototype
Util.extend(proto, props);
delete proto.statics;
delete proto.includes;
// merge options
if (proto.options) {