erikringsmuth / app-router

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

Route content might be removed incorrectly when using core-animated-pages #77

Closed plequang closed 9 years ago

plequang commented 9 years ago

Hi,

I just into this issue while using app-router. To reproduce it, go to this functional test in app-router repo : http://localhost:8080/tests/functional-tests/test-core-animated-pages.html#/first Then click twice on the '/second' link (let say you inadvertently double click on the link). Then wait 5 seconds or so, and the content of the '/second' route will disappear.

My diagnostic of this issue is the following:

  1. when you click the first time, a transition is started from previousRoute to the new route, and activeRoute is set to '/second'
  2. the second time you click, previousRoute is set to '/second' and activeRoute to '/second' as well. because you stay on the same route. And because you stay on the same route, previousRoute content is removed (see https://github.com/plequang/app-router/blob/master/src/app-router.js#L326).
  3. Few seconds later, the transition initiated in 1) ends, event 'core-animated-pages-transition-end' is fired. Function transitionAnimationEnd is called, which removes the content of previousRoute, which is unfortunately the same as the activeRoute.

I'm creating a pull request with a fix, not sure however this is the right solution.

Thanks

Pascal

erikringsmuth commented 9 years ago

Good catch! I merged the PR and tagged a new version v2.4.1.

Thanks!