Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improved feature detection with functional test in 'isEventSupported(…

…)' method, touch capable device can now be distinguished, fixes a bug that produced false positives on Chrome 4/5, bumped release date (jdalton)
  • Loading branch information...
commit 471dcb2dd32818015044f6982f39b5defd9f6fcb 1 parent 8825279
Diego Perini authored
Showing with 28 additions and 3 deletions.
  1. +28 −3 src/nwevents.js
View
31 src/nwevents.js
@@ -7,7 +7,7 @@
* Author: Diego Perini <diego.perini at gmail com>
* Version: 1.2.4beta
* Created: 20051016
- * Release: 20100314
+ * Release: 20100720
*
* License:
* http://javascript.nwbox.com/NWEvents/MIT-LICENSE
@@ -173,7 +173,29 @@
isEventSupported = W3C_MODEL ?
function(type, element) {
- return true;
+
+ if (typeof supportedEvents[type] != 'undefined') {
+ return supportedEvents[type];
+ }
+
+ function handler(e) {
+ if (Object.prototype.toString.call(e) != '[object Event]') {
+ supportedEvents[type] = true;
+ }
+ element.removeEventListener(type, handler, true);
+ }
+
+ element || (element = testTarget);
+
+ supportedEvents[type] = false;
+
+ try {
+ element.addEventListener(type, handler, true);
+ dispatch(element, type, false);
+ } catch (e) { }
+
+ return supportedEvents[type];
+
} : MSIE_MODEL ?
function(type, element) {
@@ -181,14 +203,17 @@
return supportedEvents[type];
}
+ element || (element = testTarget);
+
try {
- (element || testTarget).fireEvent('on' + type);
+ element.fireEvent('on' + type);
supportedEvents[type] = true;
} catch (e) {
supportedEvents[type] = false;
}
return supportedEvents[type];
+
} :
function () { return false; },
Please sign in to comment.
Something went wrong with that request. Please try again.