Vue-class-component: Life cycle functions never called in IE9 and 10 when using typescript

Created on 12 Nov 2017  路  9Comments  路  Source: vuejs/vue-class-component

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?

bug

Most helpful comment

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

All 9 comments

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.

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

I am experiencing the same here with chrome.

Simply put, the reason for this is

https://github.com/vuejs/vue-class-component/blob/fd737365bad081e99cb7204317cd37ce7c69f572/src/component.ts#L40

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.

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

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.

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

@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.

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

@ktsn will do

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wahidrahim picture wahidrahim  路  6Comments

spiffytech picture spiffytech  路  4Comments

tonypee picture tonypee  路  5Comments

aleksanderzubkov picture aleksanderzubkov  路  5Comments

micobarac picture micobarac  路  6Comments