OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset=utf-8> |
| 3 <title>Text.splitText()</title> |
| 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-text-splittextoffset"> |
| 5 <script src="../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../resources/testharnessreport.js"></script> |
| 7 <div id="log"></div> |
| 8 <script> |
| 9 test(function() { |
| 10 var text = document.createTextNode("camembert"); |
| 11 assert_throws("INDEX_SIZE_ERR", function () { text.splitText(10) }); |
| 12 }, "Split text after end of data"); |
| 13 |
| 14 test(function() { |
| 15 var text = document.createTextNode(""); |
| 16 var new_text = text.splitText(0); |
| 17 assert_equals(text.data, ""); |
| 18 assert_equals(new_text.data, ""); |
| 19 }, "Split empty text"); |
| 20 |
| 21 test(function() { |
| 22 var text = document.createTextNode("comté"); |
| 23 var new_text = text.splitText(0); |
| 24 assert_equals(text.data, ""); |
| 25 assert_equals(new_text.data, "comté"); |
| 26 }, "Split text at beginning"); |
| 27 |
| 28 test(function() { |
| 29 var text = document.createTextNode("comté"); |
| 30 var new_text = text.splitText(5); |
| 31 assert_equals(text.data, "comté"); |
| 32 assert_equals(new_text.data, ""); |
| 33 }, "Split text at end"); |
| 34 |
| 35 test(function() { |
| 36 var text = document.createTextNode("comté"); |
| 37 var new_text = text.splitText(3); |
| 38 assert_equals(text.data, "com"); |
| 39 assert_equals(new_text.data, "té"); |
| 40 assert_equals(new_text.parentNode, null); |
| 41 }, "Split root"); |
| 42 |
| 43 test(function() { |
| 44 var parent = document.createElement('div'); |
| 45 var text = document.createTextNode("bleu"); |
| 46 parent.appendChild(text); |
| 47 var new_text = text.splitText(2); |
| 48 assert_equals(text.data, "bl"); |
| 49 assert_equals(new_text.data, "eu"); |
| 50 assert_equals(text.nextSibling, new_text); |
| 51 assert_equals(new_text.parentNode, parent); |
| 52 }, "Split child"); |
| 53 </script> |
OLD | NEW |