| console = document.getElementById('console'); |
| li = document.createElement('li'); |
| li.appendChild(document.createTextNode(str)); |
| div = document.getElementById('duplicate'); |
| dup1 = div.parentNode.removeChild(div); |
| div = document.getElementById('duplicate'); |
| debug('Failed: getElementById returned null'); |
| if (div.firstChild.nodeValue != 'This is the second duplicate div') { |
| debug('Failed: getElementById returned the wrong div'); |
| dup2 = div.parentNode.removeChild(div); |
| if (document.getElementById('duplicate')) { |
| debug('Failed: getElementById did not return null'); |
| // Now insert the nodes again |
| container = document.getElementById('container'); |
| container.appendChild(dup1); |
| container.appendChild(dup2); |
| if (!document.getElementById('duplicate')) { |
| debug('Failed: getElementById returned null'); |
| <body onLoad="runTests()"> |
| This tests that getElementById works as elements with duplicate ids are added and removed. If the test is successful, the text "success" should be shown below. |
| <div id="duplicate">This is the first duplicate div</div> |
| <div id="duplicate">This is the second duplicate div</div> |