Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 11 years ago

#745 closed bug (fixed)

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: http://www.mondotondo.com/aercolino/jquery/improve/test/test/index3.html

Change History (10)

comment:1 Changed 16 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN.

comment:2 Changed 16 years ago by andrea

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.

comment:3 Changed 16 years ago by john

Milestone: 1.1

comment:4 Changed 16 years ago by MathieuMa

IE used absolute URLs internaly, even if they are relative (it completes them). The only way I found is the following : $("a[@href=http://]").not("[@href*='yoursite.com/']")

comment:5 Changed 16 years ago by brandon

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.

comment:6 Changed 16 years ago by joern

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.

comment:7 Changed 16 years ago by joern

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.

comment:8 Changed 16 years ago by brandon

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.

comment:9 Changed 16 years ago by Dave

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 elem.style
 		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 elem.style ... set the style

comment:10 Changed 16 years ago by brandon

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.