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(route-href): prefix the pathname for fragment hrefs #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/route-href.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export class RouteHref {

let href = this.router.generate(this.route, this.params);

// Ensure fragments are created correctly
if (href.startsWith('#') && window.location) {
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, this approach will not make it in. Though in your case it does probably fix the issue, there are two key problems. First, and most importantly, we don't and can't depend on the window object as this can be run in node in a SSR scenario. Second, this code should be relegated to the this.router.generate function.

href = `${window.location.origin}${window.location.pathname}${window.location.search}${href}`;
}

if (this.element.au.controller) {
this.element.au.controller.viewModel[this.attribute] = href;
} else {
Expand Down