Bug Tracker

Modify

Ticket #4099 (closed bug: wontfix)

Opened 4 years ago

Last modified 4 years ago

Basic #id selector fails after multiple dynamic html insert

Reported by: Mongi Owned by: john
Priority: major Milestone: 1.3.2
Component: selector Version: 1.3.1
Keywords: #id, selector, dynamic, insert Cc:
Blocking: Blocked by:

Description

Hi! I tried to upgrade from 1.2.6 to 1.3.1 and encountered a bug in selectors.

I make a function that inserts div#par with another child div#chi using .after() function. Then i call $("div#par div#chi").length and get normal value of 1. Afterwards I call the same function and it inserts div#par1 with child div#chi. But now the call $("div#par div#chi").length returns value of 0. Meanwhile $("div#par div[id=chi]") works fine.

This bug appears at least in 1.3.1 version and under all browsers except Chrome 2.0.160.0. In JQuery branch 1.2.x there is no such bug.

Demo of 1.2.6:  http://mongi.ru:8080/bug/jq127.html

Demo of 1.3.1:  http://mongi.ru:8080/bug/jq131.html

Attachments

bug.zip Download (49.8 KB) - added by Mongi 4 years ago.

Change History

Changed 4 years ago by Mongi

comment:1 Changed 4 years ago by john

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

This has to do with the fact that we're using getElementById to find the first matched element on the page - thus we can only find the first element with that ID on the page (and you have multiple elements with the same ID). I recommend generating new, unique, IDs or using [id=NAME].

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.