From d67c3b162dc10fc5fc94298edcc11bb7359c2fa2 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Wed, 14 May 2014 15:27:43 -0400 Subject: [PATCH] Fix issue with elementFromPoint when null Fixes #434 --- src/wrappers/events.js | 2 ++ test/js/Document.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/wrappers/events.js b/src/wrappers/events.js index e90ecc5..b25d999 100644 --- a/src/wrappers/events.js +++ b/src/wrappers/events.js @@ -826,6 +826,8 @@ scope.renderAllPending(); var element = wrap(originalElementFromPoint.call(document.impl, x, y)); + if (!element) + return null; var path = getEventPath(element, null); return eventRetargetting(path, self); } diff --git a/test/js/Document.js b/test/js/Document.js index c2422bc..a036b62 100644 --- a/test/js/Document.js +++ b/test/js/Document.js @@ -315,6 +315,13 @@ htmlSuite('Document', function() { assert.equal(doc.elementFromPoint(5, 5), div); }); + test('elementFromPoint null', function() { + assert.isNull(document.elementFromPoint(-9999, -9999)); + + var doc = wrap(document); + assert.isNull(doc.elementFromPoint(-9999, -9999)); + }); + test('document.contains', function() { assert.isTrue(document.contains(document.body)); assert.isTrue(document.contains(document.querySelector('body')));