Skip to content
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

Property "data" doesn't change when the route isn't active #206

Open
1 of 8 tasks
alber70g opened this issue Jul 26, 2017 · 4 comments
Open
1 of 8 tasks

Property "data" doesn't change when the route isn't active #206

alber70g opened this issue Jul 26, 2017 · 4 comments

Comments

@alber70g
Copy link

alber70g commented Jul 26, 2017

Description

app-route.data isn't changed when the route is not active according to the pattern. This results in false positives when only looking at the app-route.data.

Example

    <!-- /523 -->
    <app-route route="{{route}}"
      pattern="/:id"
      data="{{productData}}"
      active="{{idRouteActive}}">
    </app-route>

    <!-- /523/open -->
    <app-route route="{{route}}"
      pattern="/:id/:action"
      data="{{actionData}}"
      active="{{idActionActive}}">
    </app-route>

Let's say we have this route, we can add an observer _observeRoutes(productData, actionData). Then check for both of the id's, where we assume that only one can be filled.

This assumption is false: the not-active route will not have an updated app-route.data, resulting in the false positive of app-route.data.id.

Live Demo

Steps to reproduce

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
@NeoLegends
Copy link

@alber70g We just published a PR that fixes this over at #210.

@alber70g
Copy link
Author

alber70g commented Aug 9, 2017

Thank you, this is great!

@jsilvermist
Copy link

jsilvermist commented Sep 1, 2017

This is a major problem when using a subroute that expects say /category as the main page, and /category/item as the subpaths that it manages, as it completely ignores /category without this change.

PS: #210 fixes this perfectly.

@e111077
Copy link
Contributor

e111077 commented Apr 17, 2018

copying my comment from #210:

This was a feature intentionally reverted while in beta because of computational cost. It would propagate down the entire routing subtree upon each change.

Seeing as there has been repeated requests for this feature, I'd be willing to merge a non-breaking change that hides this feature behind a flag (name I have made up below is crude and I welcome suggestions), so usage would be

<app-route clear-data-on-reset route="{{route}}" data="{{firstDataClearsOnReset}}" tail="{{tail}}">
</app-route>
<app-route clear-data-on-reset route="{{tail}}" data="{{secondDataClearsOnReset}}">
</app-route>

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

Successfully merging a pull request may close this issue.

4 participants