summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/popup.js6
-rw-r--r--ext/fg/js/range.js13
2 files changed, 15 insertions, 4 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 78106319..4c2b18f7 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -62,10 +62,8 @@ class Popup {
return;
}
- const doc = this.popup.contentDocument;
- doc.open();
- doc.write(content);
- doc.close();
+ const doc = this.popup;
+ doc.srcdoc=content;
}
sendMessage(action, params, callback) {
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) {