From e17772c83008f9c74f15ab5235cf8634d2773322 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 7 Mar 2012 17:40:59 +0000 Subject: [PATCH] Added domContains() Lots of event handlers need this --- js/Utils.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/Utils.js b/js/Utils.js index dbeac64a5..534d491de 100755 --- a/js/Utils.js +++ b/js/Utils.js @@ -228,4 +228,14 @@ utils.nextTick = function(fn) { } }; +/* +Determines whether element 'a' contains element 'b' +Code thanks to John Resig, http://ejohn.org/blog/comparing-document-position/ +*/ +utils.domContains = function(a,b) { + return a.contains ? + a != b && a.contains(b) : + !!(a.compareDocumentPosition(b) & 16); +}; + })();