Skip to content

Ensure 'super' in methods and getters #71

@medikoo

Description

@medikoo

Not sure if we can rely on native super, it's likely it can't be the case, then I imagine it as:

this.super('methodName')();

Where internal implementation could be similar to:

Base.prototype.super = function (propName) {
  var currentObject = this, superObject, superValue;
  while (!currentObject.hasOwnProperty(propName)) {
    currentObject = Object.getPrototypeOf(currentObject);
    if (!currentObject) return;
  }
  superObject = Object.getPrototypeOf(currentObject);
  if (!superObject) return;
  superValue = superObject[propName]; // TODO: Take into account getter case
  if (typeof superValue === 'function') superValue = Function.prototype.bind.call(superValue, this);
  return superValue;
};

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions