Ticket #7324 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

simulate mouse events broken for IE 9

Reported by: pstadt Owned by: rdworth
Priority: minor Milestone: 1.8.18
Component: [meta] ui.test Version: 1.8.11
Keywords: Cc:
Blocking: Blocked by:

Description

I am using jquery.simulate.js for several simulated drags on my application.

Looks like IE 9 in IE 9 mode supports document.createEvent now, but the created events do not work correctly. It still supports document.createEventObject so I forced IE to use it, but I do not think it is a good solution (this is why I did not fork):

--- js/jquery.simulate.js
+++ js/jquery.simulate.js
@@ -53,7 +53,7 @@
 
                var relatedTarget = $(e.relatedTarget)[0];
 
-               if ($.isFunction(document.createEvent)) {
+               if (($.isFunction(document.createEvent)) && (!$.browser.msie)) {
                        evt = document.createEvent("MouseEvents");
                        evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail,
                                e.screenX, e.screenY, e.clientX, e.clientY,
@@ -100,7 +100,7 @@
        },
 
        dispatchEvent: function(el, type, evt) {
-               if (el.dispatchEvent) {
+               if ((el.dispatchEvent) && (!$.browser.msie)) {
                        el.dispatchEvent(evt);
                } else if (el.fireEvent) {
                        el.fireEvent('on' + type, evt);

A better solutuion, like playing with e.button values for ie9 did not help, maybe there are additional required evt attributes for IE.

Change History

comment:1 Changed 3 years ago by pstadt

Created a fiddle for this:  http://jsfiddle.net/BYJTp/

Javscript is the full actual jquery.simulate.js, other stuff is embedded in html.

comment:2 Changed 3 years ago by rdworth

  • Owner set to rdworth
  • Status changed from new to assigned

I tried your patch in Document Mode: IE9 Standards Mode and got an error "No such interface supported"

comment:3 Changed 3 years ago by rdworth

The problem seems to be that pageX and pageY values are coming through as 0. It seems these don't need to specified, browsers calculate them based on the specified clientX and clientY values. The problem is, even if I modify simulate to pass pageX and pageY values explicitly, they still come through as 0 in IE9. And these values (not clientX and clientY) are the ones the mouse plugin depends on.

comment:4 Changed 3 years ago by nickolay8

Anyone have an idea how to deal with this bug? Having exactly this problem as described with "pageX/Y"

comment:5 Changed 3 years ago by juancar74

Me too, pageX and pageY coming through as 0 !

comment:6 Changed 3 years ago by Scott González

  • Status changed from assigned to closed
  • Resolution set to fixed

Simulate: Define getters for pageX and pageY in mouse events if they come through as 0. Fixes #7324 - simulate mouse events broken for IE 9.

Changeset: e2d9b02c56ee92fa92913b451598b59a385db609

comment:7 Changed 3 years ago by Scott González

Simulate: Define getters for pageX and pageY in mouse events if they come through as 0. Fixes #7324 - simulate mouse events broken for IE 9. (cherry picked from commit e2d9b02c56ee92fa92913b451598b59a385db609)

Changeset: 0b7155f92781c59b0eb0ac8e008715d8a56671fb

comment:8 Changed 3 years ago by scott.gonzalez

  • Milestone changed from 1.9 to 1.8.18
Note: See TracTickets for help on using tickets.