Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype HTML> | |
| 2 <script src="../../resources/testharness.js"></script> | |
| 3 <script src="../../resources/testharnessreport.js"></script> | |
| 4 <script src="../assert_selection.js"></script> | |
| 5 <script> | |
| 6 test(() => assert_selection( | |
| 7 '<div contenteditable><p>A|B</p></div>', | |
| 8 'insertText \ ', | |
| 9 '<div contenteditable><p>A |B</p></div>'), | |
| 10 'insert a plain space in the middle of text node'); | |
| 11 | |
| 12 test(() => assert_selection( | |
| 13 '<div contenteditable><p id="para"></p></div>', | |
| 14 selection => { | |
| 15 var para = selection.document.getElementById('para'); | |
| 16 para.appendChild(selection.document.createTextNode('A')); | |
| 17 para.appendChild(selection.document.createTextNode('B')); | |
| 18 | |
| 19 var range = selection.document.createRange(); | |
| 20 range.setStart(para.childNodes[0], 1); | |
| 21 range.collapse(true); | |
| 22 selection.removeAllRanges(); | |
| 23 selection.addRange(range); | |
|
yosin_UTC9
2016/07/26 04:49:12
We don't need to use |Range|.
We could write: sele
| |
| 24 | |
| 25 selection.document.execCommand('insertText', false, ' '); | |
| 26 }, | |
| 27 '<div contenteditable><p id="para">A |B</p></div>'), | |
| 28 'insert a plain space between two inserted text nodes'); | |
| 29 </script> | |
| OLD | NEW |