kibu-australia / pushy

Clojurescript library for quick and easy HTML5 pushState
Eclipse Public License 1.0
223 stars 28 forks source link

'<img />' elements have 'href' field in some browsers #15

Open xsc opened 8 years ago

xsc commented 8 years ago

It seems that in some browsers (IE10/IE11 is where I saw it), <img /> DOM elements have an href which represents the path portion of the src URI, e.g.:

<img id='test' src='http://somewhere.de/image.png' />
document.getElementById('test').href
// => '/image.png'

Now, when pushy checks for (.-href target) (and only afterwards recurses through target's parents), it might pick up the image tag instead of the anchor in the following example:

<a href='/valid.png'>
  <img src='/invalid.png' />
</a>

Note that, while href is present in both IE10's and IE11's image elements, I can only observe the problematic behaviour in IE10 (and even then only on some machines, so there might exist some patched versions - or another factor I haven't discovered yet).

But, generally speaking, would it make sense to you to exclude image tags when checking for href? I'd be happy to supply a PR if desired.

Have a nice day! Yannick

AlexWheeler commented 7 years ago

I'm curious in general why is the event handler registered on document, which then traverses up to find href, and not just registered on every anchor tag?

wavejumper commented 7 years ago

@AlexWheeler @xsc see #27

xsc commented 7 years ago

@wavejumper Just out of curiosity (since I'm no longer on the project that was using pushy), are there any plans to fix those issues?