VOOZH about

URL: https://bugzilla.mozilla.org/show_bug.cgi?id=119072

⇱ 119072 - JavaScript functions in second parameter of addEventListener are ran during parsing,before listener is called


Closed Bug 119072 Opened 24 years ago Closed 24 years ago

JavaScript functions in second parameter of addEventListener are ran during parsing,before listener is called

JavaScript functions in second parameter of addEventListener are ran during parsing,before listener is called
Core
DOM: Events
Trunk
x86
Windows 98
defect
Not set
normal
Points:
---
VERIFIED INVALID
VERIFIED
INVALID
Iteration:
---
a11y-review
Accessibility Severity
Performance Impact
Size Estimate
Webcompat Priority
Webcompat Score
Tracking Status
relnote-firefox
thunderbird_esr115
thunderbird_esr140
firefox-esr115
firefox-esr140
firefox-esr153
firefox152
firefox153
firefox154
---
QA Whiteboard:
---
Has STR:
---
Change Request:
---
Bug Flags:
Signature:
None
This bug is publicly visible.

 
Reporter

Description

24 years ago
If the second parameter of addEventListener() is an actual function call, this function is called during the parsing of the script, not when the event occurs. Basicly if you have document.addEventListener("load",test(),0) in the HEAD The function test is going to be executed before the BODY is even displayed. The correct behaviour would be to generate some sort of a javascript error. this occurs on 2002-01-07-03-trunk build on windows 98
Reporter

Comment 1

24 years ago
The testcase script looks like this: function test(e) { alert("This should never be displayed because the function is never called"); } document.addEventLister("neveroccurringevent",test(),0); This event never occurs, even though the function test() is executed
This bug is invalid. If you want to add the function |test| as an event listener, do: document.addEventLister("neveroccurringevent", test, 0); that will do just that, if you do what your testcase does: document.addEventLister("neveroccurringevent", test(), 0); mozilla will try to add the return value of calling the function test() as the event listener, not the function test itself. Big difference. Mozilla does exactly what you're asking it to do here, there is no bug shown by this testcase. Marking INVALID.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
Reporter

Comment 3

24 years ago
ok
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.