aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/range.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2016-06-20 10:00:01 -0700
committerGitHub <noreply@github.com>2016-06-20 10:00:01 -0700
commit261914328fb8b72d8984a21eaf7670a01f1da2c6 (patch)
treef04b1ffd3e5d7fb9fa6047e9aeac8fde84aa4160 /ext/fg/js/range.js
parentb7901945b34cda8994f12950ce50024a6b028cee (diff)
parenta9863de95e201c8e814ad7d6dacedae98b13748a (diff)
Merge pull request #7 from ispedals/firefox
Firefox
Diffstat (limited to 'ext/fg/js/range.js')
-rw-r--r--ext/fg/js/range.js13
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) {