PolymerElements / app-route

A modular client-side router
https://www.polymer-project.org/1.0/articles/routing.html
146 stars 66 forks source link

`route-changed` fired twice with bad state #245

Open tjb1982 opened 5 years ago

tjb1982 commented 5 years ago

I'm experiencing a problem where when there were queryParams before navigating to a new URL without query params, route-changed is dispatched twice, the first time around with bad state (i.e., contains the old queryParams).

E.g., start with URL:

/context/?param=foo

route-changed is dispatched:

appRout.queryParams === {param: "foo"}

user clicks on <a href="/context">...</a>, and route-changed is dispatched:

appRoute.queryParams === {param: "foo"}

but then route-changed is immediately dispatched a second time:

appRoute.queryParams === {}

The work-around I'm using is wrapping my route-changed event handler in a 0ms-debounce, which allows the event loop to recycle and finish the required mutations to the state of the queryParams. However, route-changed is still dispatched twice.

dman777 commented 4 years ago

I am hitting this also