Bug Tracker

Ticket #1169 (closed bug: fixed)

Opened 1 year ago

Last modified 1 year ago

Selecting a form by ID fails if there's a form value element named "id" [patch]

Reported by: blueyed Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.1.3 Component: core
Version: 1.1.2 Keywords:
Cc: Needs: Review

Description

Given a FORM with ID "foo", $("#foo") will fail in Internet explorer (at least IE6) if there's a INPUT named "id". This is because "oid.id" will then refer to the (hidden) form field, but not the form's tag attribute "id" itself. It even fails when using getAttribute() explicitly.

I've fixed it like below, checking that oid.id is not an object.

Index: jquery/src/selector/selector.js
===================================================================
--- jquery/src/selector/selector.js	(Revision 1883)
+++ jquery/src/selector/selector.js	(Arbeitskopie)
@@ -229,7 +229,8 @@
    // Do a quick check for the existence of the actual ID attribute
 	// to avoid selecting by the name attribute in IE
-	if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && oid.id != m[2] )
+	// NOTE: if you have a form with a hidden field "id", IE6 will select this, even when using getAttribute instead of "oid.id"
+	if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && oid.id != m[2] && typeof oid.id != "object" )
 		oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
 	// Do a quick check for node name (where applicable) so

The patch is against SVN r1883.

Attachments

Change History

Changed 1 year ago by brandon

  • status changed from new to closed
  • resolution set to fixed

Fixed in SVN Rev [1896].

Note: See TracTickets for help on using tickets.