This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22291 - Should indexing form with "" work?
Summary: Should indexing form with "" work?
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ms2ger
QA Contact: public-webapps-bugzilla
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-06 06:21 UTC by contributor
Modified: 2013-07-11 20:12 UTC (History)
11 users (show)

See Also:


Attachments

Description contributor 2013-06-06 06:21:54 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html
Multipage: http://www.whatwg.org/C#the-form-element
Complete: http://www.whatwg.org/c#the-form-element
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
Should indexing form with "" work?

Posted from: 98.110.194.206 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20130605 Firefox/24.0
Comment 1 Boris Zbarsky 2013-06-06 06:23:39 UTC
Consider this testcase:

  <form>
    <img id="">
  </form>
  <script>
    alert(document.querySelector("form")[""]);
  </script>

Per spec as written right now this should alert an image element, I think.  That's not what it does in at least Gecko and WebKit; I haven't tested trident.

It may be better to exclude thing with empty names/ids from this named getter...
Comment 2 Ian 'Hixie' Hickson 2013-06-11 18:18:44 UTC
Questions I need to research:
Does it work with any named getters? Any based on id="" or name=""?
Comment 3 Ian 'Hixie' Hickson 2013-06-18 00:09:38 UTC
document.images['']: Firefox yes, Chrome yes, Safari no,  IE no.
select.options['']:  Firefox yes, Chrome no,  Safari no,  IE fails control.
document.embeds['']: Firefox yes, Chrome yes, Safari no,  IE no.
document.links['']:  Firefox yes, Chrome yes, Safari no,  IE fails control.
document.forms['']:  Firefox yes, Chrome yes, Safari no,  IE no.
document.all['']:    Firefox no,  Chrome no,  Safari no,  IE no.
document['']:        Firefox no,  Chrome no,  Safari no,  IE no.
window['']:          Firefox no,  Chrome no,  Safari no,  IE no.
localStorage['']:    Firefox yes, Chrome yes, Safari yes, IE yes.
form[''] (this bug): Firefox no,  Chrome no,  Safari no,  IE no.

TESTCASES:
images http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2327
options http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2328
embeds http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2329
links http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2331
forms http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2332
document.all http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2333
document http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2334
window http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2336
localStorage http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2337
form http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2338

I guess I should just omit "" names from all collections, so that everything is consistent. Any objections?
Comment 4 Boris Zbarsky 2013-06-18 02:12:57 UTC
That seems fine to me for all the HTMLCollection bits there.  I'm not sure about localStorage, since we have compat with "yes" from everyone and it's a very different beast from the rest...
Comment 5 Ian 'Hixie' Hickson 2013-07-02 21:22:01 UTC
Yeah, I'll leave localStorage.
Comment 6 Ian 'Hixie' Hickson 2013-07-02 21:45:35 UTC
Done for HTML. Reassigning to DOM Core for the HTMLCollection objects, since DOM Core took those from HTML a while back.
Comment 7 contributor 2013-07-02 21:45:44 UTC
Checked in as WHATWG revision r8010.
Check-in comment: Make the empty string no longer be a possible index for most objects that can be indexed by name.
http://html5.org/tools/web-apps-tracker?from=8009&to=8010
Comment 8 Ms2ger 2013-07-10 16:31:59 UTC
+----------------+---------------------------------------------+---------------+
| Test results   | Firefox   Chrome      Safari      IE        | spec          |
+----------------+---------------------------------------------+---------------+
| gEBTN - http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2400     |
|   namedItem    | elt       n/a         n/a         null      | null          |
|   named getter | elt       undefined   undefined   undefined | undefined     |
| gEBTNNS - http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2401   |
|   namedItem    | elt       n/a         n/a         null      | null          |
|   named getter | elt       undefined   undefined   undefined | undefined     |
| gEBCN - http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2398     |
|   namedItem    | elt       n/a         n/a         null      | null          |
|   named getter | elt       undefined   undefined   undefined | undefined     |
| children - http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2402  |
|   namedItem    | elt       elt         undefined   null      | null          |
|   named getter | elt       elt         undefined   undefined | undefined     |
+----------------+---------------------------------------------+---------------+

https://github.com/whatwg/dom/commit/35625e7dae457da7b2906b535edfe96ce6c85998