Skip to content

Life cycle functions never called in IE9 and 10 when using typescript #192

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

Closed
pcmulder opened this issue Nov 12, 2017 · 9 comments · Fixed by #203
Closed

Life cycle functions never called in IE9 and 10 when using typescript #192

pcmulder opened this issue Nov 12, 2017 · 9 comments · Fixed by #203
Labels

Comments

@pcmulder
Copy link

In IE9 and IE10, the life cycle functions are never called if I use the decorator. If I export an object, it works just fine.

Class (not working): https://github.com/pcmulder/ts-vue-class-component
Object (working): https://github.com/pcmulder/ts-vue-class-component/tree/object

Is there anything I'm missing or not getting?

@ktsn ktsn added the bug label Nov 12, 2017
@ktsn
Copy link
Member

ktsn commented Nov 12, 2017

Thanks for reporting this.

This is because IE9 and 10 does not have __proto__, then the component constructor has Vue's static properties as its own property in TypeScript. This causes unintended overwrite of components options object that includes lifecycle hooks.

@ktsn
Copy link
Member

ktsn commented Nov 12, 2017

Meanwhile you can use v6.0.0. this should not happen on that version.

@silkentrance
Copy link

I am experiencing the same here with chrome.

Simply put, the reason for this is

(options.methods || (options.methods = {}))[key] = descriptor.value

while vue-router will extract these guards directly from the def.options object

https://github.com/vuejs/vue-router/blob/d539788df8394efe41c1534e1e9d1555aa2edbe2/src/history/base.js#L262

What would be the best solution now. Register the guards on def.options or on def.options.methods? Is there even a global beforeRoute*? When not, registering these hooks on def.options should make more sense instead of registering them with def.options.methods, as the latter is actually not supported by vue-router.

@silkentrance
Copy link

As a side node, when using babel everything works just fine. Wondering why, though.

@ktsn
Copy link
Member

ktsn commented Nov 15, 2017

I saw your reproduction in vue-router issue. The reason is you are registering the hooks after declaring component. As stated in readme you have to register it before component declaration.

@silkentrance
Copy link

@ktsn hmpf, may I be so stupid? next try...

@silkentrance
Copy link

silkentrance commented Nov 15, 2017

@ktsn while your are correct in that the order by which the components are loaded and the respective hooks are registered is incorrect, even when reorganising the sources, it still fails.

@ktsn
Copy link
Member

ktsn commented Nov 15, 2017

Then could you open a new issue with the code? It probably be different issue with this issue.

@silkentrance
Copy link

@ktsn will do

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

Successfully merging a pull request may close this issue.

3 participants