Skip to main content

Search and Top Navigation

#4941 closed bug (fixed)

Opened November 03, 2009 10:09PM UTC

Closed August 11, 2011 08:49PM UTC

Mishandling of base tag

Reported by: ZeK Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.tabs Version: 1.8a1
Keywords: base tabs baseurl ui bug Cc:
Blocked by: Blocking:
Description

Hello,

i have some troubles with tabs, it doesn't manage well the base tag.

Let's say i have a page on http://www.domain.com/dir/page.html and i set a base like this :

<base href="http://www.domain.com/" />

So, if i want to have tabs, my link will look like this :

<a href="dir/page.html#mytab">My Tab</a>

But, jquery considers the tab like a remote tab.

The code is in ui.tabs.js, line 91 (on 1.8a1) :

if (hrefBase && (hrefBase === location.toString().split('#')[0] ||
(baseEl = $('base')[0]) && hrefBase === baseEl.href)) {

In my example :

  • baseEl.href = "http://www.domain.com/"
  • hrefBase = "dir/page.html"
  • location.toString().split('#')[0] = "http://www.domain.com/dir/page.html"

I can't find any example where the second line could be true. But, what could work for the base, is that :

(baseEl = $('base')[0]) && location.toString().split('#')[0] == baseEl.href+hrefBase

I tested it, works in my case.

Thanks.

Attachments (0)
Change History (4)

Changed November 03, 2009 10:51PM UTC by ZeK comment:1

My solution was a messy solution (it modifies the URL)

What seems to work better line 97 :

// inline tab
if (fragmentId.test(href)) {
	self.panels = self.panels.add(self._sanitizeSelector(href));
}

Changed by :

// inline tab
if (fragmentId.test(href) ||
(baseEl = $('base')[0]) && location.toString().split('#')[0] == baseEl.href+hrefBase) {
  self.panels = self.panels.add(self._sanitizeSelector(a.hash));
}

Changed November 17, 2009 06:13PM UTC by jzaefferer comment:2

milestone: TBD1.8

Consider using the same-domain check used by jQuery core for JSONP.

Changed January 10, 2011 02:25PM UTC by mriffault comment:3

_comment0: Here is how i fix this issue. The ZeK solution won't work for me : \ {{{ \ // inline tab \ if( $('base')[0] ) { \ var locHref = location.href; \ nvar pURL = locHref.replace($('base')[0].href, '/'); \ } \ if (fragmentId.test(href) || \ $('base')[0] && pURL == hrefBase ) { \ self.panels = self.panels.add(self._sanitizeSelector(a.hash)); \ } \ }}} \ I test if the hrefed page is the current page... So i think it is a good way to solve this problem...1294669705861769

Here is how i fix this issue. The ZeK solution didn't works for me :

// inline tab
if( $('base')[0] ) {
  var locHref = location.href;
  nvar pURL = locHref.replace($('base')[0].href, '/');
}
if (fragmentId.test(href) ||
$('base')[0] && pURL == hrefBase ) {
  self.panels = self.panels.add(self._sanitizeSelector(a.hash));
}

I test if the hrefed page is the current page... So i think it is a good way to solve this problem...

Changed August 11, 2011 08:49PM UTC by Scott González comment:4

resolution: → fixed
status: newclosed

Tabs: Fixed detection of local vs. remote tabs. Fixes #4941 - Mishandling of base tag. Fixes #4836 - Self refering href only partially detected.

Changeset: 18a3b539882835ecc78ed976a7d9e830c128fd96