diff --git a/misc/tabledrag.js b/misc/tabledrag.js index 16e9bd6..836568f 100644 --- a/misc/tabledrag.js +++ b/misc/tabledrag.js @@ -581,8 +581,9 @@ Drupal.tableDrag.prototype.dropRow = function (event, self) { */ Drupal.tableDrag.prototype.mouseCoords = function (event) { - // Match both null and undefined, but not zero, by using != instead of !==. - if (event.pageX != undefined && event.pageY != undefined) { + // Match both null and undefined, but not zero, by using != null. + // See https://stackoverflow.com/questions/2647867/how-to-determine-if-variable-is-undefined-or-null + if (event.pageX != null && event.pageY != null) { return {x: event.pageX, y: event.pageY}; } @@ -590,21 +591,21 @@ Drupal.tableDrag.prototype.mouseCoords = function (event) { // version 1.11.1; between versions 1.7 and 1.11.0 pointer events have the // pageX and pageY properties undefined. In those cases, the properties must // be retrieved from the event.originalEvent object instead. - if (event.originalEvent && event.originalEvent.pageX !== undefined && event.originalEvent.pageY !== undefined) { + if (event.originalEvent && event.originalEvent.pageX != null && event.originalEvent.pageY != null) { return {x: event.originalEvent.pageX, y: event.originalEvent.pageY}; } // Some old browsers do not support MouseEvent.pageX and *.pageY at all. // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageY // For those, we look at event.clientX and event.clientY instead. - if (event.clientX == undefined || event.clientY == undefined) { + if (event.clientX == null || event.clientY == null) { // In some jQuery versions, some events created by jQuery do not have // clientX and clientY. But the original event might have. if (!event.originalEvent) { throw new Error("The event has no coordinates, and no event.originalEvent."); } event = event.originalEvent; - if (event.clientX == undefined || event.clientY == undefined) { + if (event.clientX == null || event.clientY == null) { throw new Error("The original event has no coordinates."); } }