Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Commit caceb3b

Browse files
committed
Fix error with innerText on FFOS 1.3
1 parent 9bc37a9 commit caceb3b

2 files changed

Lines changed: 31 additions & 28 deletions

File tree

modules/editor/scripts/docIO.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ function initDocIO(document, messageProxy, loadCallback) {
2727
return doctypeString + document.documentElement.outerHTML.replace(/<(style|link)[^>]*_firetext_remove=""[^>]*>[^<>]*(?:<\/\1>)?/g, '').replace(' _firetext_night=""', '');
2828
}
2929
function getText() {
30-
return document.documentElement.innerText;
30+
var textValue;
31+
if (!('innerText' in document.documentElement)) {
32+
textValue = innerText(document.documentElement)
33+
} else {
34+
textValue = document.documentElement.innerText;
35+
}
36+
return textValue;
3137
}
3238

3339
function load(content, ft) {

scripts/lib/innertext.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
if ( (!('innerText' in document.createElement('a'))) && ('getSelection' in window) ) {
2-
HTMLElement.prototype.__defineGetter__("innerText", function() {
3-
var selection = window.getSelection(),
4-
ranges = [],
5-
str;
1+
function innerText(thisElement) {
2+
var selection = window.getSelection(),
3+
ranges = [],
4+
str;
65

7-
// Save existing selections.
8-
for (var i = 0; i < selection.rangeCount; i++) {
9-
ranges[i] = selection.getRangeAt(i);
10-
}
6+
// Save existing selections.
7+
for (var i = 0; i < selection.rangeCount; i++) {
8+
ranges[i] = selection.getRangeAt(i);
9+
}
1110

12-
// Deselect everything.
13-
selection.removeAllRanges();
11+
// Deselect everything.
12+
selection.removeAllRanges();
1413

15-
// Select `el` and all child nodes.
16-
// 'this' is the element .innerText got called on
17-
selection.selectAllChildren(this);
14+
// Select `el` and all child nodes.
15+
// 'this' is the element .innerText got called on
16+
selection.selectAllChildren(thisElement);
1817

19-
// Get the string representation of the selected nodes.
20-
str = selection.toString();
18+
// Get the string representation of the selected nodes.
19+
str = selection.toString();
2120

22-
// Deselect everything. Again.
23-
selection.removeAllRanges();
21+
// Deselect everything. Again.
22+
selection.removeAllRanges();
2423

25-
// Restore all formerly existing selections.
26-
for (var i = 0; i < ranges.length; i++) {
27-
selection.addRange(ranges[i]);
28-
}
24+
// Restore all formerly existing selections.
25+
for (var i = 0; i < ranges.length; i++) {
26+
selection.addRange(ranges[i]);
27+
}
2928

30-
// Oh look, this is what we wanted.
31-
// String representation of the element, close to as rendered.
32-
return str;
33-
})
29+
// Oh look, this is what we wanted.
30+
// String representation of the element, close to as rendered.
31+
return str;
3432
}
35-

0 commit comments

Comments
 (0)