[Pkg-javascript-commits] [dojo] 15/28: Correct detection of focusin support

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.8.6
in repository dojo.

commit 90ee9bf716b19e716841fac5355cb979f2a94f2d
Author: Colin Snover <github.com at zetafleet.com>
Date:   Tue Dec 31 15:32:44 2013 -0500

    Correct detection of focusin support
    
    Fixes #17599
    
    (cherry picked from commit e245ce5c80b85351642fd1ffc18a2d77bbbb0770)
    (cherry picked from commit ca391f932e3a3f032dd8b84566c4176857eb8ac3)
---
 on.js | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/on.js b/on.js
index 2808769..e8a4a8a 100644
--- a/on.js
+++ b/on.js
@@ -7,9 +7,26 @@ define(["./has!dom-addeventlistener?:./aspect", "./_base/kernel", "./has"], func
 		has.add("event-orientationchange", has("touch") && !has("android")); // TODO: how do we detect this?
 		has.add("event-stopimmediatepropagation", window.Event && !!window.Event.prototype && !!window.Event.prototype.stopImmediatePropagation);
 		has.add("event-focusin", function(global, doc, element){
-			// All browsers except firefox support focusin, but too hard to feature test webkit since element.onfocusin
-			// is undefined.  Just return true for IE and use fallback path for other browsers.
-			return !!element.attachEvent;
+			return 'onfocusin' in element || (element.addEventListener && (function () {
+				var hasFocusInEvent = false;
+				function testFocus() {
+					hasFocusInEvent = true;
+				}
+
+				try {
+					var element = doc.createElement('input'),
+						style = element.style;
+					style.position = 'absolute';
+					style.top = element.style.left = '0';
+					element.addEventListener('focusin', testFocus, false);
+					doc.body.appendChild(element);
+					element.focus();
+					doc.body.removeChild(element);
+					element.removeEventListener('focusin', testFocus, false);
+				} catch (e) {}
+
+				return hasFocusInEvent;
+			})());
 		});
 	}
 	var on = function(target, type, listener, dontFix){

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list