Bug 15152

Summary: (Needs test) getElementsByTagName to find sub-elements with the same id
Product: WebKit Reporter: David Gasaway <dgasaway>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, rniwa, rpaplin
Priority: P2 Keywords: HasReduction
Version: 523.x (Safari 3)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Testcase none

Description David Gasaway 2007-09-06 09:46:59 PDT
getElementsByTagName('*')['...'] doesn't work as expected when used to search for child elements where multiple parent elements have sub-elements of the same id.  Even though the element sought is in the "collection", it isn't returned when trying to access the element by name.  It works when for the first parent element, but not for subsequent parent elements.  I'll attach a test case.

Only tested in Safari 3.0.3 (522.15.5) on Windows XP.
Comment 1 David Gasaway 2007-09-06 09:48:05 PDT
Created attachment 16209 [details]
Testcase
Comment 2 David Gasaway 2007-09-06 09:51:45 PDT
Forgot to mention: works in Firefox, Opera, IE7.
Comment 3 David Kilzer (:ddkilzer) 2007-09-06 10:20:01 PDT
Confirmed with a local debug build of WebKit r25386 with Safari 3 Public Beta v. 3.0.3 (522.12.1) on Mac OS X 10.4.10 (8R218).

Comment 4 David Kilzer (:ddkilzer) 2007-09-06 10:21:35 PDT
Not a regression as the same issue occurs with Safari 2.0.4 (419.3) with original WebKit on 10.4.10.

Comment 5 David Gasaway 2007-09-06 13:29:32 PDT
FWIW, I get the same results using childNodes -- though accessing that NodeList by id doesn't seem well supported cross-browser.  Heck, now I've found that NodeList doesn't have any standard method for access by id, but it would be nice if worked consistently where it does work. :)
Comment 6 Alexey Proskuryakov 2010-09-22 13:38:53 PDT
This works in Safari 5. Not sure when this was fixed, might make sense to land a regression test.
Comment 7 David Gasaway 2010-10-29 15:41:57 PDT
Yes, seems to be fixed in both Safari 5 and Chrome 7 on Windows.
Comment 8 Ahmad Saleem 2022-08-12 04:23:56 PDT
I am not able to reproduce this issue and Comment 06 do mention it being fixed long time back, I think it was changed to upload "Regression Testcases" but we do have coverage for them in WPT now:

https://wpt.fyi/results/dom/nodes?label=master&label=experimental&aligned&view=subtest&q=getElementsByTagName

Do we need to upload anymore tests? BY THE WAY - we do fail some test around "getElementsByTagName" from WPT? I can create separate bug for them (if it already does not exist).

Appreciate if someone can update this accordingly or suggest whether I should create a separate bug for WPT failures. Thanks!
Comment 9 Ryosuke Niwa 2022-08-12 10:02:11 PDT
This is working now, and I'm pretty sure we have a test for this.