Bug 18407 - document.images with multiple named items returns back a collection
Summary: document.images with multiple named items returns back a collection
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-10 09:04 PDT by Daniel Wester
Modified: 2022-07-25 17:56 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Wester 2008-04-10 09:04:28 PDT
If you have the following on a page:
<img src="http://image1" name="myimage" />
<img src="http://image2" name="myimage" />

Then in javascript reference document.images['myimage']. In IE, Firefox and Opera this returns back a reference to one of the images. However Safari is returning back a Collection object. 

According to DOM Level 1 (HTML) http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html:
The Node with a name or id attribute whose value corresponds to the specified string. Upon failure (e.g., no node with this name exists), returns null.
Comment 1 Ahmad Saleem 2022-07-25 17:07:47 PDT
I am unable to reproduce this bug and I am not clear on web-spec and I get following behavior based on this test case (changed to JSFiddle from Comment 0):

Link - https://jsfiddle.net/atxj48fo/show

** Safari 15.6 on macOS 12.5 - <img src="http://image1" name="myimage">

** Firefox Nightly 104 - <img src="http://image1" name="myimage">

** Chrome Canary 106 - <img src="http://image1" name="myimage">

All of them are matching but not sure on web-spec so I am going to just share this much update. Thanks!