-
Notifications
You must be signed in to change notification settings - Fork 64
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
clicking links (<a> elements) with href omitted or with an empty href incorrectly generates External UrlRequest's #55
Comments
As far as I can tell, this is how things work in plain HTML:
|
Hmm, indeed. I'm not able to read that from the spec(s), though it seems Elm kind of accidentally does the right thing then. And while it would still seem technically correct to generate an |
This was reported on browser already: #34 |
Ah, thanks @MethodGrab! And a proposed fix is in elm/virtual-dom, so it seems the issue is well-covered. I'd close this if it weren't for the issue with empty (as opposed to omitted) hrefs that's not covered by that issue and fix. I'll happily migrate this issue to a more suitable project though. |
I just ran in to this too, in the context of an a tag with an onClick attribute but no href specified at all. A possible fix, provided you aren't relying on fragment identifiers in the same context, is to add a |
In the mean-time, a docs update would be highly appreciated. |
Empty links, i.e.
a
elements without ahref
attribute or withhref ""
will causeExternal
UrlRequest
s to be generated, and if handled as suggested in the Elm guide will cause page reloads.This can be handled in
update
if you know about it, but is non-standard behavior that I think would surprise most people. it is also behavior that a lot of code depends on, among themelm-bulma
, and it miight therefore not be immediately apparent what the cause is.As far as I can understand, the standard behavior is:
href
is omitted it should not be considered a hyperlink (source)href
is an empty string, it should be considered a reference to the beginning of the document (source)My suggestion is to simply not emit a
UrlRequest
ifhref
is omitted, and to emit anInternal
UrlRequest
if it is an empty string.Here's a minimal, complete and verifiable example:
My solution/workaround is to add a branch in update to do nothing on
External ""
. For others coming across this looking for an easy fix, here's the fixedupdate
function:The text was updated successfully, but these errors were encountered: