Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure 'super' in methods and getters #71

Open
medikoo opened this issue Jul 21, 2016 · 0 comments
Open

Ensure 'super' in methods and getters #71

medikoo opened this issue Jul 21, 2016 · 0 comments
Assignees

Comments

@medikoo
Copy link
Owner

medikoo commented Jul 21, 2016

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;
};
@medikoo medikoo self-assigned this Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant