Closed Bug 35377 Opened 25 years ago Closed 23 years ago

MouseEvent object type incorrectly [object KeyEvent]

Categories

(Core :: DOM: Events, defect, P3)

x86
Other
defect

Tracking

()

VERIFIED INVALID
Future

People

(Reporter: joe, Assigned: joki)

References

Details

(Keywords: dom2)

Attachments

(1 file)

Whenever I check the type of a mouse event (using .toString()) it tells me it's an object of class "KeyEvent". According to the DOM, shouldn't that be "MouseEvent" ? The name doesn't really matter, I'm just making sure it's the right class in the first place. Most DOM MouseEvent properties seem to be in place anyway.
Attached file test case
DOM Level 2 events, over to you joki...
Assignee: jst → joki
joe@joehewitt.com - are you still seeing this problem with recent builds of Mozilla? If so, we'll get this bug confirmed. Gerv
OK, I see this one on 2000-05-27 under W95. Gerv
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
This bug has been marked "future" because the original netscape engineer working on this is over-burdened. If you feel this is an error, that you or another known resource will be working on this bug,or if it blocks your work in some way -- please attach your concern to the bug for reconsideration.
Target Milestone: --- → Future
Still exists in 2000071220
Related or dupe of this is also bug 63692.
*** Bug 63692 has been marked as a duplicate of this bug. ***
I believe this bug is found in nsJSKeyEvent.cpp (generated file). Both MouseEvent and KeyEvent use the same JSClass KeyEventClass, which defines the class name to be "KeyEvent".
Summary: KeyEvent should be MouseEvent → MouseEvent object type incorrectly [object KeyEvent]
I rememberd this being discussed before and I can't say I agree that this is really a bug, it doesn't hurt in any way, it's just the name of a class, no functionality is lost because of this. IIRC we're meerely reusing code and that's why we have the same name for MouseEvent and KeyEvent objects. Unless there's a good reason to fix this that I'm not aware of I'd say this is INVALID. And, this will change once the DOM code uses XPConnect.
Well, you COULD have code that checked if (event.toString() == "[object MouseEvent]") or something... ;) So I don't think this can be invalid, but WONTFIX might do... By the way, initMouseEvent method cannot be used (I think, haven't tested), need this patch(?): Index: nsDOMPropEnums.h =================================================================== RCS file: /cvsroot/mozilla/dom/public/nsDOMPropEnums.h,v retrieving revision 3.103 diff -u -r3.103 nsDOMPropEnums.h --- nsDOMPropEnums.h 2000/12/10 09:25:52 3.103 +++ nsDOMPropEnums.h 2001/01/02 19:50:59 @@ -674,6 +674,7 @@ NS_DOM_PROP_KEYEVENT_CHARCODE, NS_DOM_PROP_KEYEVENT_CTRLKEY, NS_DOM_PROP_KEYEVENT_INITKEYEVENT, + NS_DOM_PROP_KEYEVENT_INITMOUSEEVENT, NS_DOM_PROP_KEYEVENT_KEYCODE, NS_DOM_PROP_KEYEVENT_METAKEY, NS_DOM_PROP_KEYEVENT_SHIFTKEY, Index: nsDOMPropNames.h =================================================================== RCS file: /cvsroot/mozilla/dom/public/nsDOMPropNames.h,v retrieving revision 3.93 diff -u -r3.93 nsDOMPropNames.h --- nsDOMPropNames.h 2000/12/10 09:25:52 3.93 +++ nsDOMPropNames.h 2001/01/02 19:50:59 @@ -672,6 +672,7 @@ "keyevent.charcode", \ "keyevent.ctrlkey", \ "keyevent.initkeyevent", \ + "keyevent.initmouseevent", \ "keyevent.keycode", \ "keyevent.metakey", \ "keyevent.shiftkey", \
Heikki, yes, one could do if (event.toString() == "[object MouseEvent]") but there's no guarantee that works across browsers or even across versions of browsers, the real way of finding out if an event is of a given type is to check the event.type member, that's standard and portable. As for your patch, I doubt that patch fixes anything (I didn't look into the problem either so I could be wrong).
The patch does not fix anything. I tried to check it in as part of another bug, but vidur (being the sr) found that it is useless and initMouseEvent should probably be callable as is (otherwise we would be unable to compile). Long live the review system... ;)
Keywords: dom2
Component: DOM Level 2 → DOM Events
*** Bug 76352 has been marked as a duplicate of this bug. ***
QA Contact Update
QA Contact: vidur → vladimire
The generated events are now all of [object Event] type... this is invalid
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
vfy
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: