erikringsmuth / app-router

Router for Web Components
https://erikringsmuth.github.io/app-router/
MIT License
611 stars 83 forks source link

anchor links #10

Closed ghost closed 10 years ago

ghost commented 10 years ago

because everything is evaluated client side some things are different

in the data-binding-page.html page if i add an in page anchor it self evaluates incorrectly by the browser engine to : http://127.0.0.1:49399/pages/data-binding-page.html#anchor1 Here is the html in the page.

Anchor link


Anchor text

How to tell polymer to evaluate the path at runtime properly ???

erikringsmuth commented 10 years ago

I think this is related to HTML imports and the way they wrote the spec. Every relative path (src and href) is relative to the directory that the imported file is inside. This includes anchor tag hrefs that start with #.

These are example links from a page imported from /pages/data-binding-page.html.

<a href="/"></a> -> / non-relative paths work fine <a href="/home"></a> -> /home non-relative paths work fine <a href="#/home"></a> -> /pages/data-binding-page.html#/home * the weird looking one <a href="/#/home"></a> -> /#/home making all hash paths off of the root / makes it work <a href="other-page.html"></a> -> /pages/other-page.html (not a great example since this is probably a custom element) <link rel="import" href="/elements/example-element.html"></a> -> /elements/example-element.html <link rel="import" href="../elements/example-element.html"></a> -> /elements/example-element.html

I think <a href="/#/home"></a> -> /#/home is the format you need for hash paths.

Alternatively, if you can get your static content server to always return index.html, then you can use regular paths like /home.

I hope this helps get you in the right direction. I should probably write up some documentation with a good set of examples and put it on the gh-pages.

ghost commented 10 years ago

Look at this though:

All i did was extend the data binding page with 2 links. The link inside the page fails the link outside the page works