Skip to content

my.Class does not inherit constructors by default #6

@ntrrgc

Description

@ntrrgc

I don't know if this is expected behavior or not, but at least it was unexpected (and undesired) for me. The behavior should be changed or clarified in the documentation.

Although my.Class inherits methods and properties fine, the constructor is skipped, defaulting to an empty function in all cases.

This is due to this code:

if (body.constructor === Object) {
  Class = function() {};
} else {
  Class = body.constructor;
  delete body.constructor;
}

To get constructor inheritance I changed that into this code:

if (body.constructor === Object) {
  if (SuperClass === null) {
    Class = function() { };
  } else {
    Class = function() {
      SuperClass.apply(this, arguments);
    };
  }
} else {
  Class = body.constructor;
  delete body.constructor;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions