Closed
Bug 283646
Opened 20 years ago
Closed 9 years ago
Can't get "document.forms.elementName" if form's name is "forms"
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: harunaga, Unassigned)
References
()
Details
(Keywords: regression)
If a form's name is "forms", "document.forms.xxx" has no properties on
nightly build.
Steps:
1. go to the URL
2. click "test"
Result:
returns "undefined".
No problem if a form's name is "form".
http://bugzilla.mozilla.gr.jp/attachment.cgi?id=2612&action=view
WFM with Mozilla 1.7.5 and Firefox 1.0.
regression.
| Reporter | ||
Updated•20 years ago
|
Summary: "document.forms.xxx" has no properties on nightly build → "document.forms.x" has no properties if form's name is "forms"
| Reporter | ||
Updated•20 years ago
|
Summary: "document.forms.x" has no properties if form's name is "forms" → Can't get "document.forms.elementName" if form's name is "forms"
Comment 1•20 years ago
|
||
The behavior seems correct to me... See discussion in bug 240633 (which is where
the "regression" comes from). document.forms should be the forms array, not a
particular DOM node.
| Reporter | ||
Comment 2•20 years ago
|
||
Yes, the behavior of Safari 1.2.4 is same as current Mozilla.
But this works with IE 6.0, Opera 7.54, Netscape 4.7x and Mozilla 1.7.5
and some major site uses this legacy script...
ex.
http://www.ecat.sony.co.jp/avacc/headphone/spec_compare.cfm?B2=92&B3=399
(in Japanese, sorry)
Comment 3•20 years ago
|
||
In IE, document.forms can be both the form and the forms array at the same time,
last I checked (test document.forms[0] to see whether I'm mis-remembering)...
That said, we do have some inconsistencies here. For example, I can name a node
"getElementById" and have it accessible via document.getElementById, but I can't
use "forms".... We should pick one or the other and do it.
Comment 4•20 years ago
|
||
Test result on the test case (<form name="forms">)
javascript:x=document.forms;y=document.forms[0];alert(x+" / "+y);
returned:
(1.7.5) HTMLFormElement / HTMLInputElement
"forms" was NAME.
document.forms[array-position] format("forms" as reserved word)
was not usable to get FormElement on 1.7.5
if user defined form named "forms".
(1.8x) HTMLCollection / HTMLFormElement
"forms" was reserved word.
document.forms.xxx format("forms" as user defined name)
was not usable on 1.8.x when user defined form named "forms".
document.forms["forms"] worked as expected.
(IE 6) forms / input1
undefined
(javascript:x=document.forms;y=document.forms[0]; )
( alert(x.name+" / "+y.name); )
( z=document.forms["forms"]; alert(z); )
IE6 returned FormElement for document.forms
when form named "forms" is defined.
And document.forms[XX] ("forms" as reserved word) was not usable.
This is same behaviour as 1.7.5.
Both "document.forms('forms' as reserved word)" and "document.forms('forms' as
form element name)" are array(HTMLCollection and HTMLFormElement)
then '[' can not be a key to distinguish,
although "getElementById" can be distinguished by '('.
Boriss, can support both way when user defined "form named 'forms'"?
I prefer 1.8.x way to 1.7.5 way, because no need of care on reserved word when
using DOM-0 way(document.forms[FORM-NAME].elements[...]).
But killing of reserved word of "forms" for document.forms like IE is reasonable
if "Quriks mode" and if user defined form element named "forms", for
compatibility reason, because this kind of HTML is usually tested on IE only.
Comment 5•20 years ago
|
||
> Boriss, can support both way when user defined "form named 'forms'"?
I'm not sure what you're asking.
It's also not clear to me what the IE behavior is, according to you...
Comment 6•20 years ago
|
||
(In reply to comment #5)
> I'm not sure what you're asking.
My question was:
When user defined form named "forms" and forms named others,
<form name="forms"> <input name="input1"></form>
<form name="NORMAL_FORM_NAME"><input name="input2"></form>
can Mozilla support access thru document.forms.input1 ('.forms' as user defined
form name) without breaking access thru
document.forms["NORMAL_FORM_NAME"].input2 ('.forms' as reserved word), or vice
versa?
(Similar question on <input name="links">, <img name='images">, ...)
It's possible if hierarchical variable name for compiler(which permits override
of reserved word and permits ambigous variable name specification. eg. PL/I).
But this is object. "document.forms" can't be ambigous...
Sorry for my silly question.
Comment 7•20 years ago
|
||
> can Mozilla support access thru document.forms.input1 ('.forms' as user defined
> form name) without breaking access thru
> document.forms["NORMAL_FORM_NAME"].input2 ('.forms' as reserved word), or vice
> versa?
Not really, given that document.forms needs to be either a form object or a list
of forms object. Can't really be both...
Updated•16 years ago
|
Assignee: general → nobody
QA Contact: ian → general
Comment 9•9 years ago
|
||
User Agent Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0
Build ID 20160324153548
Could not reproduce on current Firefox release (v. 45.0.1) nor on latest Nightly (48.0a1), so closing this as WFM. If anyone can reproduce on a current build, fell free to reopen the bug.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•