Skip to content

feat: accept UrlTree in navigate and initialRoute - #603

Open
gabrielmethot wants to merge 1 commit into
testing-library:mainfrom
gabrielmethot:feat/navigate-url-tree
Open

gabrielmethot wants to merge 1 commit into
testing-library:mainfrom
gabrielmethot:feat/navigate-url-tree

Conversation

@gabrielmethot

Copy link
Copy Markdown

Hello,

This pull request adds new signatures to navigate and initialRoute to allow passing instances of UrlTree. This makes query params easier to configure because Angular handles the serialization. It also lets us pass a route fragment, which wasn't supported with string paths.

String paths work the same as before, but they behave differently from a UrlTree because they go through the library's own parser, which doesn't decode values or handle fragments. This can be surprising, so I documented it in the JSDoc.

It might be worth considering using Angular's parser as the default, because that's probably what most developers expect. The custom query params parser could then be deprecated. Since this would be a breaking change, it might fit better in a future major version. I'd love to hear your thoughts about this.

Thanks for taking the time to review this, and for your work on the library!

@timdeschryver timdeschryver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing this, @gabrielmethot.

Do you think this should also be added to the zoneless API (public_api.ts)?

I鈥檓 asking because I鈥檇 like to keep it as minimal as possible. Since this is essentially just router.navigate([path]), I鈥檓 not sure it鈥檚 needed there. AFAIK, most component tests aren鈥檛 concerned with routing logic itself.

You can ignore the failed build, I will look into it.

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.

2 participants