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

Extending or Aliasing a Class #40

Open
ghost opened this issue Oct 24, 2016 · 2 comments
Open

Extending or Aliasing a Class #40

ghost opened this issue Oct 24, 2016 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented Oct 24, 2016

Example, I have to tags that are identical, except the tag names are different.

@template(`<hero-form><yield/></hero-form>`)
export class HeroForm extends Riot.Element implements IHeroForm {
      getContainer():JQuery {},
      mounted():void {},
      bindSumbit():void {}
}

// ... later 

@template(`<enquire-form><yield/></enquire-form>`)
export class EnquireForm extends HeroForm {

  constructor(){
    super();
  }

  getContainer():Jquery {
   return super.getContainer();
  }

mounted():void {
   return super.mounted();
  }
 /// ...etc, this seems dirty to me, but aside from using a mixin can this be implemented better?
}

Am I missing something here? I have to keep calling the super on the child class otherwise I lose context.

@nippur72 nippur72 added the bug label Oct 24, 2016
@nippur72
Copy link
Owner

It seems there's a problem in the way we transfer properties from the typescript class object to the riot tag object. The transfer is limited to properties in element.prototype only and thus it does not consider the chain of inheritance.

In other words it copies methods and properties from the class but skipping methods and properties from its ancestors. Normally this isn't a problem because most of the times you extend from Riot.Element, and I guess that's why we haven't noticed the issue before.

I will mark this as a bug, but I expect it to be automatically fixed with riot 3, since we will have a true ES6 Riot.Tag class to extend from.

@ghost
Copy link
Author

ghost commented Oct 24, 2016

Ok. Thanks for update.

I can't see this being too much of an issue at the moment. I will just use the super calls and refactor it later when riot 3 arrives.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant