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

Reentrancy breaks property decorators #104

Closed
SLaks opened this issue Jun 14, 2017 · 3 comments
Closed

Reentrancy breaks property decorators #104

SLaks opened this issue Jun 14, 2017 · 3 comments
Labels

Comments

@SLaks
Copy link

SLaks commented Jun 14, 2017

When using the pattern of

@Component({
  components: { foo: require('./foo.vue') }
})
class ...

foo.vue's class will be created during the initialization of its calling class.
This will end up applying all property decorators (eg, @Watch from https://github.com/kaorun343/vue-property-decorator) to Foo instead of the calling class.

To fix this, you need to change $decoratorQueue to a stack so that you can differentiate between properties applied to different reentrant class definitions.

@ktsn
Copy link
Member

ktsn commented Jun 14, 2017

Could you explain more details what a problem you encounters?
I'm afraid I can't understand why we need to change $decoratorQueue to a stack.
I think it should be a queue to make consistent with the order of applying the native decorators.

@SLaks
Copy link
Author

SLaks commented Jun 15, 2017

It looks like the problem only happens with TypeScript's decorator compilation, not Babel.

Repro: https://jsfiddle.net/SLaks/stuf0kex/3/

Typing in the first textbox does nothing (doesn't display a message from the watch handler).
Commenting out components: { Child: require('child') } (or changing the language to Babel) makes it work.

@ktsn
Copy link
Member

ktsn commented Jun 19, 2017

Thanks for the repro. It seems like we need to assign $decoratorQueue for each class constructor to avoid to apply property decorators to wrong components.

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

2 participants