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

Polymer rewrites anchor hrefs #4213

Closed
robdodson opened this issue Dec 12, 2016 · 6 comments
Closed

Polymer rewrites anchor hrefs #4213

robdodson opened this issue Dec 12, 2016 · 6 comments

Comments

@robdodson
Copy link
Contributor

robdodson commented Dec 12, 2016

Description

A relative url inside the href of an anchor element inside a Polymer element gets rewritten to be relative to the import.

For instance, if my element lives in src/elements

Something like <a href="foo"> becomes <a href="/src/elements/foo">. While this behavior is desirable for things like CSS and images, it is not desirable for anchors as it messes up the ability to do routing with relative paths. This is especially important because Polymer's rewrite happens in a way that ignores the <base> element, meaning if you want to serve your project from a subdirectory (like GH pages) you can't easily use <base> to tack on the subdir.

cc @sorvell @justinfagnani

@sorvell
Copy link
Contributor

sorvell commented Feb 25, 2017

This needs to be updated in Polymer and the HTMLImports polyfill. Tools will also need to be updated. We'll also need to add an option to Polymer 1.x

sorvell pushed a commit that referenced this issue Feb 28, 2017
…e loadable resources (inline style and src attribute). This avoids scoping things like <a> href to template import location which is almost always not what the user wants. When this automated re-writing fails, users should fix url's via binding or imperative code.
@kevinpschaaf
Copy link
Member

Resolved in 2.x via #4357.

This will be resolved in 1.x via #4367 once that change lands by using the pattern <a href="[[rootPath]]relativeToRoot.html"> in 1.x, since paths with bindings are not rewritten.

@FluorescentHallucinogen
Copy link
Contributor

Is this issue fixed and can be closed?

@robdodson
Copy link
Contributor Author

Pretty sure it can. I'll close it and see if anything explodes 🙈

@jfrazzano
Copy link

jfrazzano commented Jul 10, 2017 via email

@robdodson
Copy link
Contributor Author

@jfrazzano you can see what the fix does here:
#4357 (comment)

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

No branches or pull requests

6 participants