erikringsmuth / app-router

Router for Web Components
https://erikringsmuth.github.io/app-router/
MIT License
610 stars 83 forks source link

Imported template that contains a nested template will not be removed correctly from app-route #83

Closed plequang closed 9 years ago

plequang commented 9 years ago

Hi,

Using the following route definition

<app-route path="/example" import="/pages/template-page.html" template></app-route>

If "template-page.html" contains a nested template, then the content of the route won't be removed correctly when you leave this route.

Example of a template containing a nested template :

<template>
    <template is="auto-binding">
        <h2>Auto-binding template</h2>
    </template>
</template>

This is because in removeRouteContent(), app-router tries to not remove inline templates: https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L375

erikringsmuth commented 9 years ago

I made a few more changes to your PR to also support auto-binding templates inside of a non-imported inline template. https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L376

Try out the changes and let me know if it all works as expected. If it looks good I'll bump the version to 2.4.2.

plequang commented 9 years ago

Ah yes, I forgot this use case. Your changes are working perfectly. Thanks.

erikringsmuth commented 9 years ago

I ended up doing another rewrite https://github.com/erikringsmuth/app-router/compare/5cb84356733519b2ffa92a331ee0a2cefeca0cd3...master.

I introduced a new variable loadingRoute and delayed updating previousRoute and activeRoute until later. This solves a lot of the timing issues in a much more sane way. There aren't as many 1-off checks for core-animated-pages anymore.

I'll see if I can get through anymore issues in the next day or two but I'll release v2.4.2 with the changes soon.