Bug 6006 - document.getElementById does not behave in the same way as Internet Explorer (Win)
Summary: document.getElementById does not behave in the same way as Internet Explorer ...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 15127 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-12-08 03:57 PST by Andrew Wellington
Modified: 2019-02-06 09:02 PST (History)
6 users (show)

See Also:


Attachments
Simple demonstration page (530 bytes, text/html)
2005-12-08 03:59 PST, Andrew Wellington
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Wellington 2005-12-08 03:57:59 PST
In Internet Explorer, document.getElementById() in JavaScript will return form elements (input, select, etc) 
but not other elements (p, div, etc) with the same name as the id being requested (even if their id is 
different to the name). This causes some IE-specific JavaScript to fail on Safari as it (rightly according to 
the specifications) ignores the name when finding the elements requested.

An affected product is the eService administration interface from Right Now software (http://
www.rightnow.com/eservice.html) although this interface does claim to only support IE 5.5+.

A sample test case will be attached to this bug shortly.
Comment 1 Andrew Wellington 2005-12-08 03:59:27 PST
Created attachment 5000 [details]
Simple demonstration page
Comment 2 Andrew Wellington 2005-12-08 04:09:37 PST
To clarify, when IE walks the tree looking for elements that match the document.getElementById() request, 
it returns the first element that matches:
  - id is equal to requested id
  - element is a form element, and its name matches the requested id
Comment 3 Gavin Kistner 2006-01-17 07:27:02 PST
If any such broken behavior is introduced, it should be only exist in some alternative 'compliant' mode. IE 
is simply wrong, and steadily losing market share. Suggest you change this bug to invalid.

(Some believe that 'de facto' standards present in other browsers are more important than the Standards 
themselves. I believe the opposite. Matching the spec instead of IE is not a 'bug'. I accept that there are 
people with both opinions; I do not know which opinion drives Safari's development team.)
Comment 4 Alexey Proskuryakov 2007-11-07 13:03:10 PST
*** Bug 15127 has been marked as a duplicate of this bug. ***
Comment 5 Alexey Proskuryakov 2007-11-07 13:04:08 PST
From bug 15127:

Opera has this quirk, but is apparently going to remove it from their 9.50 release:

"Removed IE-compatibility where Document.getElementById treated name and id
attributes the same, which caused problems with jQuery."

Comment 6 Alexey Proskuryakov 2007-11-25 02:49:21 PST
This causes major problems at the site of Beeline, a major mobile provider in Russia. Affected pages are only available to customers.
Comment 7 Anantha Keesara 2007-12-27 17:58:05 PST
"http://markets.themarker.com/tmc/investorGuide.jhtml?layer=investorGuide" (a major Israeli finance portal also has this issue)
Comment 8 Simon Pieters (:zcorpan) 2008-11-26 04:10:14 PST
Is this still an issue?

# [13:14] <zcorpan> it seems we have lots of bugs saying that getElementById works with name=''
# [13:14] <zcorpan> which we dropped in 9.5
# [13:15] <zcorpan> and no bugs on it not working with name='', afaict
# [13:15] <zcorpan> also, i think ie8 doesn't look at name='' (in ie8 mode)
Comment 9 Ryosuke Niwa 2015-10-16 00:58:22 PDT
This is no longer the case with newer versions of IE (e.g. IE9).
Comment 10 Lucas Forschler 2019-02-06 09:02:47 PST
Mass moving XML DOM bugs to the "DOM" Component.