Bug Tracker

Modify

Ticket #951 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

$('#foo') conflates id and <a name>

Reported by: chad@… Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc:
Blocking: Blocked by:

Description

Steps to Reproduce

  1. Load the following HTML in IE 6 or 7:
<html>
<head>
  <script src="jquery.js"></script>
</head>
<body>

  <a name="foo">MUAHAHAHAHA!!!</a>
  <p id="foo">Greetings, program!</p>
  <input type="button" value="Greetings, program!"
         onclick="alert($('#foo').html());" /> &lt;= broken in IE6/7

  <hr />

  <p name="bar">MUAHAHAHAHA!!!</p>
  <p id="bar">Greetings, program!</p>
  <input type="button" value="Greetings, program!"
         onclick="alert($('#bar').html());" />

  <hr />

  <a id="baz">Greetings, program!</a>
  <p name="baz">MUAHAHAHAHA!!!</p>
  <input type="button" value="Greetings, program!"
         onclick="alert($('#baz').html());" />

</body>
</html>
  1. Click on the first button

Expected Result

"Greetings, program!" in the alert box

Actual Result

"MUAHAHAHAHA!!!" in the alert box

Notes

The name attribute only clobbers the id attribute when name is on an anchor tag, as the other two instances on the above page demonstrate.

The bug appears in IE 6 and 7, but not in Firefox 1.5.

This is with jQuery 1.1.1.

Change History

comment:1 Changed 6 years ago by brandon

There is ongoing discussion about this ticket in this  thread on the dev list. I've provided a  test page and  patch in the thread for further discussion.

comment:2 Changed 6 years ago by brandon

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in  Revision 1406.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.