Hash link in anchor tags for imported elements

463 views
Skip to first unread message

Justin Merz

unread,
May 18, 2014, 6:40:14 PM5/18/14
to polym...@googlegroups.com
Not sure if this is a bug or I am missing something, but I have put together to following test. https://github.com/jrmerz/polymer-hash-test/blob/master/public/index.html, sorry I didn't use jsbin, not sure how use it with imports for this example.  The anchor tag works fine in the element defined in index.html.  But if you look at test-two https://github.com/jrmerz/polymer-hash-test/blob/master/public/test-two.html you will see the anchor tags work great in the <template repeat="">...</template> but the <a href="#bad">Bad Hash Link</a> is turned into <a href="test-two.html#bad">Bad Hash Link</a>.  Thoughts, ideas, suggestions?

-Thanks
Justin

Rob Dodson

unread,
May 19, 2014, 12:39:44 PM5/19/14
to polym...@googlegroups.com
Hm that's weird. You can remove the element defined in index.html because it doesn't do anything. It seems like the real problem is that hash links inside of a repeating template inside of an imported element do the right thing. And links outside a repeating template in an imported element do the wrong thing.

Rob Dodson

unread,
May 19, 2014, 12:42:32 PM5/19/14
to polymer-dev, Daniel Freedman
[+ dfreedm]

Stripped down gist is here

Daniel, any idea what's going on here?

Justin Merz

unread,
May 19, 2014, 6:49:59 PM5/19/14
to polym...@googlegroups.com, Daniel Freedman
I defined the element in index.html to demonstrate the working version.

I am confused as to why you would say that #bad is doing the right thing.  Clicking that link will take you to that element as a new page in the browser.  When should updating the hash via a href take you to a new page?

Rob Dodson

unread,
May 19, 2014, 6:54:22 PM5/19/14
to Justin Merz, polymer-dev, Daniel Freedman
On Mon, May 19, 2014 at 3:49 PM, Justin Merz <jrm...@gmail.com> wrote:
I defined the element in index.html to demonstrate the working version.

I am confused as to why you would say that #bad is doing the right thing.  Clicking that link will take you to that element as a new page in the browser.  When should updating the hash via a href take you to a new page?


I said "It seems like the real problem is that hash links inside of a repeating template inside of an imported element do the right thing." The #ok links are the ones in the repeating template. They seem to be doing the right thing IMO. #bad is outside the repeating template, and is doing the wrong thing.
 

On Monday, May 19, 2014 9:42:32 AM UTC-7, Rob Dodson wrote:
[+ dfreedm]

Stripped down gist is here

Daniel, any idea what's going on here?


On Mon, May 19, 2014 at 9:39 AM, Rob Dodson <robd...@google.com> wrote:
Hm that's weird. You can remove the element defined in index.html because it doesn't do anything. It seems like the real problem is that hash links inside of a repeating template inside of an imported element do the right thing. And links outside a repeating template in an imported element do the wrong thing.


On Sunday, May 18, 2014 3:40:14 PM UTC-7, Justin Merz wrote:
Not sure if this is a bug or I am missing something, but I have put together to following test. https://github.com/jrmerz/polymer-hash-test/blob/master/public/index.html, sorry I didn't use jsbin, not sure how use it with imports for this example.  The anchor tag works fine in the element defined in index.html.  But if you look at test-two https://github.com/jrmerz/polymer-hash-test/blob/master/public/test-two.html you will see the anchor tags work great in the <template repeat="">...</template> but the <a href="#bad">Bad Hash Link</a> is turned into <a href="test-two.html#bad">Bad Hash Link</a>.  Thoughts, ideas, suggestions?

-Thanks
Justin


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/18e77b02-fa90-4d6a-8e01-53a68eddff0e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Rob Dodson

unread,
May 19, 2014, 6:55:07 PM5/19/14
to Justin Merz, polymer-dev, Daniel Freedman
Basically I'm agreeing with you. #bad is doing the wrong thing. It shouldn't open a new page.

Justin Merz

unread,
May 19, 2014, 6:57:55 PM5/19/14
to Rob Dodson, polymer-dev, Daniel Freedman
I apologize, got a little confused on your semantics.
--
Justin Merz -- Land, Air, and Water Resources -- University of California
Davis, CA 95616-8628

kct...@big2.net

unread,
Jul 20, 2014, 8:11:07 PM7/20/14
to polym...@googlegroups.com, jrm...@gmail.com, dfr...@google.com
Any update/bug filed for this issue where I can check the status? I am hitting similar issue with Polymer 0.3.4.

Justin Merz

unread,
Jul 20, 2014, 11:07:02 PM7/20/14
to kct...@big2.net, polym...@googlegroups.com, Daniel Freedman

I still have to use method calls to update the hash.  Can we file a ticket somewhere?

Rob Dodson

unread,
Jul 21, 2014, 6:18:38 PM7/21/14
to Justin Merz, Steve Orvell, kct...@big2.net, polymer-dev, Daniel Freedman
+ sorvell

Steve, does this seem like an imports bug? I noticed that <a href="#bad"> actually gets converted to <a href="x-foo.html#bad"> in the devtools. Why would it change the href on my anchor tags?


Steve Orvell

unread,
Jul 21, 2014, 6:40:02 PM7/21/14
to Rob Dodson, Justin Merz, kct...@big2.net, polymer-dev, Daniel Freedman
This is not a bug as per the current design, but it's odd and we should probably change it. Polymer considers all path related attributes to be relative to the importing document.

I suggest filing this issue against Polymer.

Rob Dodson

unread,
Jul 21, 2014, 7:20:22 PM7/21/14
to Steve Orvell, Justin Merz, Kin Chuen Tang, polymer-dev, Daniel Freedman

Elliott Sprehn

unread,
Jul 21, 2014, 10:00:11 PM7/21/14
to Rob Dodson, Steve Orvell, Justin Merz, Kin Chuen Tang, polymer-dev, Daniel Freedman
Polymer won't do it if there's an expression in there, I had to work around this annoying behavior by doing:

href="{{ _hack_ }}#hash" where _hack_ is always undefined so it doesn't impact the href at all, but polymer will stop expanding the url.

Rob Dodson

unread,
Jul 22, 2014, 10:31:06 AM7/22/14
to Elliott Sprehn, Steve Orvell, Justin Merz, Kin Chuen Tang, polymer-dev, Daniel Freedman
Hm good to know. At least there's a temporary workaround. Thanks Elliott :)
Reply all
Reply to author
Forward
0 new messages