Bug Tracker

Modify

Ticket #4134 (closed bug: invalid)

Opened 4 years ago

Last modified 15 months ago

Selectors with multiple identical id is not works

Reported by: shagren Owned by:
Priority: major Milestone: 1.3.2
Component: unfiled Version: 1.3.1
Keywords: Cc:
Blocking: Blocked by:

Description

Please look for next code

    <div id="t">
        <span id="t">
                some content
        </span>
    </div>
    <a href="#" onclick="javascript: alert($('div#t div#t').length); return false;">Click me</a>

I see empty result when click. With 1.2.6 - works good. With 1.3.1 and nightly build(r6170) works bad. When id is not identical works good.

Change History

comment:1 Changed 4 years ago by Markus.Staab

its no valid html to have several elements with an equal id.. id hast to be unique

comment:2 Changed 4 years ago by dmethvin

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

Right, ID attributes need to be unique. If they are not the browser can do something unpredictable.

comment:3 Changed 4 years ago by shagren

  • Status changed from closed to reopened
  • Resolution invalid deleted

Yes, but it is works in 1.2.x. Then it can break old code. Then need return old behavior or document changes somewhere.

comment:4 Changed 4 years ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to invalid

Sorry, but jQuery can't guarantee consistent behavior across browsers when the document is invalid, and duplicate id attributes are such a case.

Your test case returns 0 in both 1.2.6 and 1.3.1, which seems correct even if duplicate id attributes were allowed. There is no div#t in the document that has a descendent div#t!

If you feel this merits further discussion, please do not reopen the ticket; take it to the jQuery Dev group.

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.