Closed Bug 67691 Opened 24 years ago Closed 24 years ago

anonymous functions cause Event problems after switching windows

Categories

(Core :: DOM: Events, defect)

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 31847

People

(Reporter: kwindla, Assigned: joki)

References

()

Details

Attachments

(2 files)

Adding anonymous functions as part of Events to an element (using addEventListener) works great initially. Problems arise when: 1) using a page that includes anonymous functions as Events, then 2) switching to do something in another Mozilla window, then 3) returning to the original page and triggering the Events Usually, the anonymous-function-based Events just stop working (until the page they are on is reloaded.) But often Mozilla crashes shortly after trying to invoke the anonymous-function-based Events, as well. Here is my test case: <html> <head> <title>DOM anon funcs added-events-after-window-switch bug isolation</title> </head> <body> <div id="container">click here to change text</div> <script> function test_func () { if ( container.toggle ) { container.innerHTML = 'some placeholder text for state one'; container.toggle = false; } else { container.innerHTML = 'not really very different placeholder text for the other state'; container.toggle = true; } } var container = document.getElementById ( 'container' ); container.toggle = true; // this works: // container.addEventListener ( 'click', test_func, false ); // this doesn't after doing anything in any other window container.addEventListener ( 'click', function() { test_func() }, false ); </script> </body> </html>
I see this with a Linux cvs build from 2001-02-05 morning. Steps to reproduce: 1) open two mozilla windows 2) load http://mozilla.org in window #1 3) load the provided testcase in window #2 4) follow a link in window #1 5) click on the text in window #2 and watch it not change. setting status to new.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Reassigning to the owner of the event code.
Assignee: jst → joki
I just attached a test case that shows the same behavior with a named, nested function definition, rather than with an anonymous function. Named and nested functions seem to work in some sections of my code. But in other places they exhibity the same problem as the anonymous functions. I haven't been able to figure out how to know why some work and some don't -- but the test case does reproduce the problem behavior.
I believe both of these cases are dupes of 31847. Definitely the first case, probably the second as well. This is scheduled to be addressed soon. *** This bug has been marked as a duplicate of 31847 ***
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
Component: DOM Level 2 → DOM Events
verified. this is fixed now that the fix for 31847 was checked in.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: