Skip to main content

Bug Tracker

Side navigation

#745 closed bug (fixed)

Opened December 29, 2006 12:07AM UTC

Closed February 10, 2007 10:04PM UTC

Last modified March 13, 2012 07:03PM UTC

Attribute Begins With (a[@href ^= 'http://www']) fails in IE

Reported by: Andrea Ercolino Owned by:
Priority: major Milestone:
Component: core Version:
Keywords: attribute Cc:
Blocked by: Blocking:

This is the test number 33.10 of the test suite, and works in FF, but fails in IE.

The failure is due to the fact that in IE a href="#" is seen as if it was href="http://domain/path/to/page#", so the bug shows up whenever the domain begins with www, like here:

Attachments (0)
Change History (10)

Changed December 30, 2006 10:13AM UTC by joern comment:1

resolution: → fixed
status: newclosed

Fixed in SVN.

Changed December 30, 2006 05:52PM UTC by andrea comment:2

resolution: fixed
status: closedreopened

I'm not sure of the fact that the bug is closed. Joërn has changed the test suite, so that the test succeeds, but the 'bug' is still there, or am I wrong?

Let me explain how I see the issue (maybe it is not a bug?): There is a difference between FF and IE that should be taken care of, because of the abstraction layer jQuery is.

I'm not sure of what the solution should be, but if asking for an href, FF says "#" and IE says "http://domain/path/to/page#" then this is a difference jQuery users must remember in order to get a uniform behavior, which in turn jQuery should provide by default in my opinion.

I think that FF's answer is better, so a solution could be to filter hrefs and remove document location before the first '#', if any.

Then the changes to the test suite should be reverted.

Changed January 07, 2007 11:08PM UTC by john comment:3

milestone: 1.1

Changed January 08, 2007 07:03PM UTC by MathieuMa comment:4

IE used absolute URLs internaly, even if they are relative (it completes them).

The only way I found is the following :


Changed January 31, 2007 04:45PM UTC by brandon comment:5

This used to be fixed using the getAttribute flags in IE but was removed because it was causing larger issues with XML. If memory serves me correctly.

Changed January 31, 2007 09:58PM UTC by joern comment:6

Added (back) a test for this, see revision 1243.

Maybe the getAttribute flag check could be used only when checking the href attribute, I'm not sure how that should look like. It's true that is was removed due to enormous problems when dealing with XML.

Changed February 05, 2007 02:54PM UTC by joern comment:7

The necessary code is this:

element.getAttribute(’href’, 2)

Just need to isolate that when working with XML documents. If I remember it correctly, IE likes to completely screw up when it encounters that code, no matter if the method is actually executed or not, it just executes it and fails miserably, catching the exception isn't possible.

Changed February 07, 2007 02:58PM UTC by brandon comment:8

resolution: → fixed
status: reopenedclosed

This is now fixed in revision 1293

The test is temporarily removed until an issue with the test suite can be resolved. However, the fix does work.

Changed February 10, 2007 04:45PM UTC by Dave comment:9

resolution: fixed
status: closedreopened

Are you sure the fix works? It's indexing an Array with a string, I don't see how that can be right. This patch worked for me with a test file using href, but the existing one did not. Or am I missing something?

Index: jquery.js
--- jquery.js	(revision 1321)
+++ jquery.js	(working copy)
@@ -1495,8 +1495,6 @@
 			selected: "selected"
-		var fixIE = jQuery.isXMLDoc(elem) ? [] : "href,src,background,cite,classid,codebase,data,longdesc,profile,usemap".split(',');
 		// IE actually uses filters for opacity ... elem is actually
 		if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
 			// IE has trouble with opacity if it does not have layout
@@ -1527,7 +1525,9 @@
 		// IE elem.getAttribute passes even for style
 		else if ( elem.tagName ) {
 			if ( value != undefined ) elem.setAttribute( name, value );
-			if ( jQuery.browser.msie && fixIE[name] ) return elem.getAttribute( name, 2 );
+			if ( jQuery.browser.msie && !jQuery.isXMLDoc(elem) &&
+					/^(href|src|background|cite|classid|codebase|data|longdesc|profile|usemap)$/.test(name) )
+				return elem.getAttribute( name, 2 );
 			return elem.getAttribute( name );
 		// elem is actually ... set the style

Changed February 10, 2007 10:04PM UTC by brandon comment:10

resolution: → fixed
status: reopenedclosed