#4836 closed enhancement (fixed)
Self refering href only partially detected
Reported by: | aschild | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.tabs | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Given the following constelation:
Page URL: MyPage.html
In the page source we have this:
<ul class="navtab"> <li><a href="MyPage.html#Overview">Overview</a></li> <li><a href="MyPage.html#Images">Images</a></li> </ul>
The 1.7.2 version of UI.tabs does not detect that we point to ourself and loads the page twice and the result is not what we expect.
The solution is to look if the href is only a page name, and if yes, look if it's identical tou our own url.
Here the code which fixes this problem, it starts arround line 85 of the ui.tabs.js
// For dynamically created HTML that contains a hash as href IE < 8 expands // such href to the full page url with hash and then misinterprets tab as ajax. // Same consideration applies for an added tab with a fragment identifier // since a[href=#fragment-identifier] does unexpectedly not match. // Thus normalize href attribute... var hrefBase = href.split('#')[0], baseEl; var onlyLocation= location.toString().split('#')[0]; var locArray= onlyLocation.split('/'); var lastElement= locArray[locArray.length-1]; if (hrefBase && (hrefBase === location.toString().split('#')[0] || (baseEl = $('base')[0]) && hrefBase === baseEl.href) || (hrefBase.indexOf('/') == -1 && hrefBase == lastElement) ) { href = a.hash; a.href = href; }
Would be great if it could be included in a future version. There is still one case not catched, when the href is "./MyPage.html", then it still goes wrong, but so far we did not have that case.
Attached is a diff
Attachments (1)
Change History (5)
Changed 14 years ago by
Attachment: | ui.tabs.js.diff added |
---|
comment:1 follow-up: 2 Changed 14 years ago by
Milestone: | TBD → 1.next |
---|
Can't you just fix those hrefs to include only the hash?
comment:2 Changed 13 years ago by
Replying to joern.zaefferer:
Can't you just fix those hrefs to include only the hash?
Probably, but I imagine there are template engines that automatically formats URL's to start from the site root. Mine doesn't, but this 'bug' cost me an hour to figure out because I do format my URL's this way. My point being that this is unexpected behaviour.
comment:3 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Tabs: Fixed detection of local vs. remote tabs. Fixes #4941 - Mishandling of base tag. Fixes #4836 - Self refering href only partially detected.
Changeset: 18a3b539882835ecc78ed976a7d9e830c128fd96
comment:4 Changed 12 years ago by
Milestone: | 1.next → 1.9 |
---|
Diff file with the enhancement