Open Bug 264343 Opened 20 years ago Updated 2 years ago

variable context loss when overloading onsubmit

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Windows 2000
defect

Tracking

()

People

(Reporter: trash, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; rv:1.7.3) Gecko/20041001 Firefox/0.10.1

When overloading a form's onsubmit event, the scope of the "this" object is
lost, and "this" becomes a reference to the window object within the original code.

I'm not certain that this qualifies as a bug, but it does represent different
behavior from /that/other/evIl/browsEr/.  IE's treatment seems more intuitive.

Reproducible: Always
Steps to Reproduce:
Create a form with an onsubmit event that references the "this" object.
Use javascript to modify that event by capturing a reference to it, and calling
that reference.  EG:
	var theForm = document.getElementById("myForm");
	var oldSubmitCodeRef = theForm.onsubmit;
	theForm.onsubmit = function(e){
		return oldSubmitCodeRef(e);
	}

Execute the form's submit event and observe that the scope of "this" within the
original code no longer references the form object.
Actual Results:  
"this" becomes a reference to the window.

Expected Results:  
"this" should have continued to be a reference to the form.
Attached file Test case
Rhino has nothing to do with mozilla/firefox. 
Component: Core → DOM
Product: Rhino → Core
Version: other → Trunk
Assignee: igor → general
QA Contact: pschwartau → ian
Assignee: general → nobody
QA Contact: ian → general
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: