yourguide.com.au - document.aName.submit() fails due to scoping(?)/aliasing(?)

RESOLVED INCOMPLETE

Status

Tech Evangelism Graveyard
English Other
RESOLVED INCOMPLETE
16 years ago
3 years ago

People

(Reporter: Chris Bitmead, Unassigned)

Tracking

Details

(Whiteboard: [bug248549notfixed], URL)

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

16 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc2)
Gecko/20020510
BuildID:    2002051006

The above form and javascript doesn't work,
but it does in IE.

Reproducible: Always
Steps to Reproduce:
1.Put in a comment etc.
2.Press "Submit"
3.

Actual Results:  Nothing happens

Expected Results:  Form submitted

Comment 1

16 years ago
Hmm, interesting. The script fails doing 'document.aFormName.submit()' which 
should be legal. It appears that some odd scoping issue is clobbering the 
submit property of the Form object. This is the simplest testcase that I could
reduce this into. (Ignore the fact that the testcase doesn't make any sense; 
it's just what's left over from a form validation scheme that the original 
URL was using (encoding meta-information in each element's NAME attribute)).

<html>
<head>
<script>
function checkform() {
    len = document.addopinion.elements.length;
    for (i = 0; i < len; i++) {
        split_name(document.addopinion[i].name);
    }
    document.addopinion.submit();
}
function split_name(name) {
    ary = name.split(",");
    document.addopinion[i].name = ary[0];
}
</script>
</head>
<body>
<form action="http://www.mozilla.org/" name="addopinion" method="GET">
    <input type="text" name="subject,Subject,0,0" value="Try to submit">
    <input type="button" value="Submit" name="submit,Submit,0,0"
           onClick="return checkform()">
</form>
</body>
</html>
Status: UNCONFIRMED → NEW
Ever confirmed: true

Updated

16 years ago
Summary: Form / Javascript not working → document.aName.submit() fails due to scoping(?)/aliasing(?)

Comment 2

16 years ago
Created attachment 86017 [details]
minimal testcase from above;

Comment 3

16 years ago
Oh, wait. Simpler. What a pain if we have to emulate that.

<script>
function checkform() {
    alert("1: " + document.aForm.submit);
    alert("2: " + document.aForm.whatever);
    document.aForm[0].name = 'submit';
    alert("3: " + document.aForm.submit);
    document.aForm.submit();
}
</script>
</head>
<body>
<form action="http://www.mozilla.org/" name="aForm" method="GET">
    <input type="button" value="Whatever" name="whatever"
           onClick="return checkform()">
</form>
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale

Comment 4

16 years ago
Created attachment 86018 [details]
simpler case; assigning the name of an element to be 'submit' clobbers the Form objects 'submit' method
Attachment #86017 - Attachment is obsolete: true

Comment 5

16 years ago
... although the second testcase works in Nav4x/win32
Keywords: 4xp

Comment 6

16 years ago
cc'ing Boris, because this looks the same as

bug 148782 "Javascript works in 4.75 but not in Mozilla build"
bug 148793 "Defined FORM object ignores submit() method"


In each of those cases, as here, there is an HTML element given
the name "submit". The only difference is that here, the element
is named dynamically and not statically as in the other two bugs.


Q: is it just a coincidence that we've had three different reports
   on this in one day???

Comment 7

16 years ago
*** Bug 148885 has been marked as a duplicate of this bug. ***

Comment 8

16 years ago
cc'ing David from the duplicate bug 148885.
That makes four reports on this problem in 24 hours! 

Comment 9

16 years ago
Seems like an odd coincidence. I tried the above testcase in 3/17/02 and 
12/16/01 trunk builds, and they both fail the same way.
I think Hixie filed a more completely-stated bug against which this could be
dup'ed, actually.

/be

*** This bug has been marked as a duplicate of 147058 ***
Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → DUPLICATE
This is not a dupe of Hixie's scoping bug, we scope things exactly like IE does
here, the problem here is that form.submit is a callable object in IE even if
it's an image or a form control.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
This has never "worked" in Mozilla, so the fact that we got all these reports 
is basically a coincidence, yes.

Phil, what exactly does ECMA say about what should happen when foo.bar() is 
called and foo.bar is not a Function object?
bzbarsky, there's nothing in ECMA to help here.  A "host object" can be
callable, in addition to a function object.  SpiderMonkey supports callable
objects, too -- see JSClass.call.

/be
Actually, the problem here is actually not that inputs named submit in IE are
callable objects, the problem is that the name to object hash off of form[] is
static in IE and live in mozilla, i.e. setting the name of an input to 'foo' in
mozilla will make the input reachable as form.foo, whereas that is not the case
in IE. From what I can tell, that's simply a bug in IE, and I don't see that we
want to emulate that bug in mozilla. Over to evangelism.
Assignee: jst → doron
Status: REOPENED → NEW
Component: DOM Level 0 → US General
Product: Browser → Tech Evangelism
QA Contact: desale → zach
Version: other → unspecified

Comment 16

16 years ago
Note dynamic name assignment to 'submit' does occur at this site, but
not in the duplicate bugs above. For example, from bug 148782:

              <input type="image" name="submit"  etc.

Comment 17

16 years ago
What's the final decision on this bug ? 
Mozilla does the right thing here IMNSHO, form.elements should be live, just
like all other node lists are, so if you change the name of a form control it
should appear in form.elements with that name. I find it hard to justify any
other kind of behavior here.

Comment 19

15 years ago
-> en non us
Assignee: doron → momoi
Component: US General → English: Non-US
QA Contact: zach → jeesun
Summary: document.aName.submit() fails due to scoping(?)/aliasing(?) → yourguide.com.au - document.aName.submit() fails due to scoping(?)/aliasing(?)

Comment 20

15 years ago
Mass reassigning English-Other bugs to general default assignees.
Assignee: momoi → english-other
QA Contact: jeesun → english-other

Updated

14 years ago
Keywords: 4xp
Whiteboard: [bug248549notfixed]

Comment 21

7 years ago
INCOMPLETE due to lack of activity since the end of 2009.

If someone is willing to investigate the issues raised in this bug to determine whether they still exist, *and* work with the site in question to fix any existing issues, please feel free to re-open and assign to yourself.

Sorry for the bugspam; filter on "NO MORE PRE-2010 TE BUGS" to remove.
Status: NEW → RESOLVED
Last Resolved: 16 years ago7 years ago
Resolution: --- → INCOMPLETE
Product: Tech Evangelism → Tech Evangelism Graveyard
You need to log in before you can comment on or make changes to this bug.