|
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; |
6 | 5 |
|
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 | + } |
11 | 10 |
|
12 | | - // Deselect everything. |
13 | | - selection.removeAllRanges(); |
| 11 | + // Deselect everything. |
| 12 | + selection.removeAllRanges(); |
14 | 13 |
|
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); |
18 | 17 |
|
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(); |
21 | 20 |
|
22 | | - // Deselect everything. Again. |
23 | | - selection.removeAllRanges(); |
| 21 | + // Deselect everything. Again. |
| 22 | + selection.removeAllRanges(); |
24 | 23 |
|
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 | + } |
29 | 28 |
|
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; |
34 | 32 | } |
35 | | - |
0 commit comments