From 71ea118e4d675c42632c93d36328d7a40707dc88 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 17 Feb 2014 10:44:02 -0600 Subject: [PATCH] range.getBoundingClientRect check for null, fixes #580 --- js/utils/dom.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/js/utils/dom.js b/js/utils/dom.js index 114e4fa41e..3a477117f7 100644 --- a/js/utils/dom.js +++ b/js/utils/dom.js @@ -38,18 +38,19 @@ range.selectNodeContents(textNode); if(range.getBoundingClientRect) { var rect = range.getBoundingClientRect(); + if(rect) { + var sx = window.scrollX; + var sy = window.scrollY; - var sx = window.scrollX; - var sy = window.scrollY; - - return { - top: rect.top + sy, - left: rect.left + sx, - right: rect.left + sx + rect.width, - bottom: rect.top + sy + rect.height, - width: rect.width, - height: rect.height - }; + return { + top: rect.top + sy, + left: rect.left + sx, + right: rect.left + sx + rect.width, + bottom: rect.top + sy + rect.height, + width: rect.width, + height: rect.height + }; + } } } return null;