diff options
author | ispedals <ispedals@users.noreply.github.com> | 2016-06-18 18:52:02 -0400 |
---|---|---|
committer | ispedals <ispedals@users.noreply.github.com> | 2016-06-19 12:54:32 -0400 |
commit | 099d48ef48a065001a6b4a0ab29c567935af1f25 (patch) | |
tree | a6fef1a2d2c74bd2850794e498d85aaa0fb36f55 /ext | |
parent | 651231fbc136ad2574c18d837151aa4dd6c2306e (diff) |
Polyfill caretRangeFromPoint()
Gecko did not implment the older caretRangeFromPoint() and instead
implemented the newer caretPositionFromPoint()
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fg/js/range.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/fg/js/range.js b/ext/fg/js/range.js index 182e242c..0befe279 100644 --- a/ext/fg/js/range.js +++ b/ext/fg/js/range.js @@ -16,6 +16,19 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +// Polyfill caretRangeFromPoint() using the newer caretPositionFromPoint() +if (!document.caretRangeFromPoint){ + document.caretRangeFromPoint = function polyfillcaretRangeFromPoint(x,y){ + let range = document.createRange(); + let position = document.caretPositionFromPoint(x,y); + if (!position) { + return null; + } + range.setStart(position.offsetNode, position.offset); + range.setEnd(position.offsetNode, position.offset); + return range; + }; +} class Range { constructor(range) { |