]> git.parisson.com Git - pdf.js.git/commitdiff
fix for opera DSK-354448: onclick fired on disabled nodes with opaque content
authorSteffen Märcker <merkste@web.de>
Mon, 16 Apr 2012 17:17:49 +0000 (19:17 +0200)
committerSteffen Märcker <merkste@web.de>
Mon, 16 Apr 2012 17:17:49 +0000 (19:17 +0200)
web/compatibility.js

index 9f139b7dd9beb793e8ffe4f2eb9a77c2f58b7a9d..b63ba35d8f59ae84c67521c12c3055f99d55da82 100644 (file)
     console = {log: function() {}};
   }
 })();
+
+// Check console compatability
+(function checkOnClickCompatibility() {
+  // workaround for reported Opera bug DSK-354448:
+  // onclick fires on disabled buttons with opaque content
+  function ignoreIfTargetDisabled(event) {
+    if (isDisabled(event.target)) {
+      event.stopPropagation();
+    }
+  }
+  function isDisabled(node) {
+    return node.disabled || (node.parentNode && isDisabled(node.parentNode));
+  }
+  if (navigator.userAgent.indexOf('Opera') != -1) {
+    // use browser detection since we cannot feature-check this bug
+    document.addEventListener('click', ignoreIfTargetDisabled, true);
+  }
+})();
\ No newline at end of file