Closed
Bug 995795
Opened 11 years ago
Closed 11 years ago
initMouseEvent() and number of parameters (D2E vs D3E spec)
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: crimsteam, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release)
Build ID: 20140314220517
Steps to reproduce:
In D2E this method define 15 parameters (http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-Event-initMouseEvent)
D3E introduces one new buttons property (https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-MouseEvent-buttons). Firefox support buttons but not in initMouseEvent method (https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#h4_idl-interface-MouseEvent-initializers). Passing 16 arguments to initMouseEvent() throws error. I don't know if changing this behavior would not be too invasive for the already created code. Maybe detect how many arguments were passed, if 15 use old way, if 16 new way.
Chrome take 16 arguments but in general does not support buttons property (we have undefined). IE support buttons property but not in initMouseEvent(), we can pass more than 15 argumetns and do not get any error.
So, at now only Firefox throw error. Even if this method is mark as deprecated should be implemented correctly.
Comment 1•11 years ago
|
||
I guess we could add another initMouseEvent method which takes 16 arguments.
But as of now, D3E isn't backwards compatible with D2E.
In which case does Gecko throw if you pass 16 arguments? There can be type error, which is correct.
Reporter | ||
Comment 2•11 years ago
|
||
Of course TypeError. Fast test:
<script>
var mouseEvent1 = document.createEvent("MouseEvent");
mouseEvent1.initMouseEvent("hello", true, true, window,
69, 50, 100, 150,
200, true, true, true,
true, 1, 7, document.documentElement); // remove 7 for Firefox
document.write(mouseEvent1); // [object MouseEvent]
document.write("<br>");
document.write(mouseEvent1.type); // hello
document.write("<br>");
document.write(mouseEvent1.bubbles); // true
document.write("<br>");
document.write(mouseEvent1.cancelable); // true
document.write("<br>");
document.write(mouseEvent1.view); // window
document.write("<br>");
document.write(mouseEvent1.detail); // 69
document.write("<br>");
document.write(mouseEvent1.screenX); // 50
document.write("<br>");
document.write(mouseEvent1.screenY); // 100
document.write("<br>");
document.write(mouseEvent1.clientX); // 150
document.write("<br>");
document.write(mouseEvent1.clientY); // 200
document.write("<br>");
document.write(mouseEvent1.altKey); // true
document.write("<br>");
document.write(mouseEvent1.ctrlKey); // true
document.write("<br>");
document.write(mouseEvent1.metaKey); // true
document.write("<br>");
document.write(mouseEvent1.shiftKey); // true
document.write("<br>");
document.write(mouseEvent1.button); // 1
document.write("<br>");
document.write(mouseEvent1.buttons); // 7 (missing in all browser)
document.write("<br>");
document.write(mouseEvent1.relatedTarget); // [object HTMLHtmlElement]
document.write("<br>");
document.write(mouseEvent1.defaultPrevented); // false
document.write("<br>");
document.write(mouseEvent1.isTrusted); // false
document.write("<br>");
document.write(mouseEvent1.eventPhase); // 0
document.write("<br>");
document.write(mouseEvent1.timeStamp); // depends on the browser
document.write("<br>");
document.write(mouseEvent1.currentTarget); // null
document.write("<br>");
document.write(mouseEvent1.target); // null
</script>
Reporter | ||
Comment 3•11 years ago
|
||
Maybe it will better if D3E spec add this new parameter at the end of method, sth like this:
void initMouseEvent (DOMString type, boolean bubbles, boolean cancelable,
Window? view, long detail, long screenX,
long screenY, long clientX, long clientY,
boolean ctrlKey, boolean altKey, boolean shiftKey,
boolean metaKey, short button, EventTarget? relatedTarget,
unsigned short buttons);
Redundant arguments will never cause an error, and if necessary someday the browser could redefine initMouseEvent(). In this method we have so many arguments that remember their order is very hard, moving buttons at the end should not be a big problem, just more compatibile with D2E.
Comment 4•11 years ago
|
||
it should be [optional].
but I think adding another version of initMouseEvent which has buttons as second to last param
is ok per webidl.
Reporter | ||
Comment 5•11 years ago
|
||
Ok, I opened a bug for this case (https://www.w3.org/Bugs/Public/show_bug.cgi?id=25346). If anyone are interested please share your comments/ideas.
Reporter | ||
Comment 6•11 years ago
|
||
D3E spec delete buttons parameter in initMouseEvent(), so nothing need change. If there are no objections you can close this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•