Search and Top Navigation
#4836 closed enhancement (fixed)
Opened September 04, 2009 02:10PM UTC
Closed August 11, 2011 08:49PM UTC
Last modified August 11, 2011 08:50PM UTC
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 (4)
Changed November 17, 2009 06:06PM UTC by comment:1
milestone: | TBD → 1.next |
---|
Changed November 29, 2010 04:32PM UTC by comment:2
Replying to [comment:1 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.
Changed August 11, 2011 08:49PM UTC by comment:3
Changed August 11, 2011 08:50PM UTC by comment:4
milestone: | 1.next → 1.9 |
---|
Can't you just fix those hrefs to include only the hash?