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

fix(RouterStore): serialize routeConfig inside the default serializer #1384

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

timdeschryver
Copy link
Member

@timdeschryver timdeschryver commented Oct 28, 2018

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The routeConfig isn't being serialized in DefaultRouterStateSerializer.

Issue Number: #1363

What is the new behavior?

The routeConfig is being serialized in DefaultRouterStateSerializer.
Note that not all properies are being serialized:

{
    // was already being serialized
    component?: Type<any>;

	// added properties to be serialized
    path?: string;
    pathMatch?: string;   
    redirectTo?: string;
    outlet?: string;

    // not being serialized
    matcher?: UrlMatcher;  
    canActivate?: any[];
    canActivateChild?: any[];
    canDeactivate?: any[];
    canLoad?: any[];
    data?: Data;
    resolve?: ResolveData;
    children?: Routes;
    loadChildren?: LoadChildren;
    runGuardsAndResolvers?: RunGuardsAndResolvers;
}

Does this PR introduce a breaking change?

[x] Yes
[ ] No

The default router serializer now returns a null value for routeConfig when routeConfig doesn't exist on the ActivatedRouteSnapshot instead of an empty object.
BEFORE:

{
 "routeConfig": {}
}

AFTER:

{
 "routeConfig": null
}

Other information

If this doesn't belong in the default serializer, feel free to close.
It's always possible for the impacted users to create there own serializer.

Closes #1363

routeConfig: {
component: route.routeConfig ? route.routeConfig.component : undefined,
},
routeConfig: route.routeConfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the routeConfig remain an empty object if its not defined to keep the existing behavior?

Copy link
Member Author

@timdeschryver timdeschryver Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially wanted to do this, but the Angular docs defines it as Route | null.
I wanted to stay as close as possible to this.

I should've payed more attention to when this... because this means that this is a breaking change.

What do you think of it? Should I change this to an empty object or flag this as a breaking change and add it to the migration log?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag is as a breaking change. I'd rather the behavior be consistent and this would be the time to break it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this? I have some troubles to properly word this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

BREAKING CHANGE:

The default router serializer now returns a `null` value for
`routeConfig` when `routeConfig` doesn't exist on the
`ActivatedRouteSnapshot` instead of an empty object.

BEFORE:

```json
{
  "routeConfig": {}
}
```

AFTER:

```json
{
  "routeConfig": null
}
```
@timdeschryver timdeschryver force-pushed the pr/serialeze-routeconfig branch from 5b2b44c to 92ab3bd Compare October 29, 2018 20:03
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 88.371% when pulling 92ab3bd on pr/serialeze-routeconfig into 0e38673 on master.

@brandonroberts brandonroberts merged commit 18a16d4 into master Oct 30, 2018
@timdeschryver timdeschryver deleted the pr/serialeze-routeconfig branch March 16, 2019 20:03
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 this pull request may close these issues.

DefaultRouterStateSerializer: path property missing in routeConfig
3 participants