OLD | NEW |
1 <p>This tests Selection::addRange(). It should have no effect if the range pass
ed to it does not intersect the currently selected range. '3456' should be sele
cted.</p> | 1 <p>This tests Selection::addRange(). It should have no effect if the range pass
ed to it does not intersect the currently selected range. '3456' should be sele
cted.</p> |
2 <div id="div">123456789</div> | 2 <div id="div">123456789</div> |
3 | 3 |
4 <script> | 4 <script> |
5 var sel = window.getSelection(); | 5 var sel = window.getSelection(); |
6 var div = document.getElementById("div"); | 6 var div = document.getElementById("div"); |
7 var text = div.firstChild; | 7 var text = div.firstChild; |
8 | 8 |
9 var range = document.createRange(); | 9 var range = document.createRange(); |
10 range.setStart(text, 3); | 10 range.setStart(text, 3); |
11 range.setEnd(text, 5); | 11 range.setEnd(text, 5); |
12 sel.addRange(range); | 12 sel.addRange(range); |
13 | 13 |
| 14 range = document.createRange(); |
14 range.setStart(text, 4); | 15 range.setStart(text, 4); |
15 range.setEnd(text, 6); | 16 range.setEnd(text, 6); |
16 sel.addRange(range); | 17 sel.addRange(range); |
17 | 18 |
| 19 range = document.createRange(); |
18 range.setStart(text, 2); | 20 range.setStart(text, 2); |
19 range.setEnd(text, 3); | 21 range.setEnd(text, 3); |
20 sel.addRange(range); | 22 sel.addRange(range); |
21 | 23 |
22 // This should have no effect (until we support discontiguous selections) since
this range doesn't intersect the currently selected range. | 24 // This should have no effect (until we support discontiguous selections) since
this range doesn't intersect the currently selected range. |
| 25 range = document.createRange(); |
23 range.setStart(text, 7); | 26 range.setStart(text, 7); |
24 range.setEnd(text, 8); | 27 range.setEnd(text, 8); |
25 sel.addRange(range); | 28 sel.addRange(range); |
26 | 29 |
27 // Ditto. | 30 // Ditto. |
| 31 range = document.createRange(); |
28 range.setStart(text, 0); | 32 range.setStart(text, 0); |
29 range.setEnd(text, 1); | 33 range.setEnd(text, 1); |
30 sel.addRange(range); | 34 sel.addRange(range); |
31 | 35 |
32 </script> | 36 </script> |
OLD | NEW |