| OLD | NEW |
| (Empty) |
| 1 description("This test checks the implementation of the ElementTraversal API."); | |
| 2 | |
| 3 debug('Test with no children'); | |
| 4 var noChildren = document.createElement('div'); | |
| 5 | |
| 6 shouldBe("noChildren.firstElementChild", "null"); | |
| 7 shouldBe("noChildren.lastElementChild", "null"); | |
| 8 shouldBe("noChildren.previousElementSibling", "null"); | |
| 9 shouldBe("noChildren.nextElementSibling", "null"); | |
| 10 shouldBe("noChildren.childElementCount", "0"); | |
| 11 | |
| 12 debug('Test with no element children'); | |
| 13 var noElementChildren = document.createElement('div'); | |
| 14 noElementChildren.appendChild(document.createComment("comment but not an element
")); | |
| 15 noElementChildren.appendChild(document.createTextNode("no elements here")); | |
| 16 | |
| 17 shouldBe("noElementChildren.firstElementChild", "null"); | |
| 18 shouldBe("noElementChildren.lastElementChild", "null"); | |
| 19 shouldBe("noElementChildren.previousElementSibling", "null"); | |
| 20 shouldBe("noElementChildren.nextElementSibling", "null"); | |
| 21 shouldBe("noElementChildren.childElementCount", "0"); | |
| 22 | |
| 23 debug('Test with elements'); | |
| 24 var children = document.createElement('div'); | |
| 25 children.appendChild(document.createComment("first comment")); | |
| 26 var first = document.createElement('p'); | |
| 27 children.appendChild(first); | |
| 28 children.appendChild(document.createComment("a comment")); | |
| 29 var last = document.createElement('p'); | |
| 30 children.appendChild(last); | |
| 31 children.appendChild(document.createComment("last comment")); | |
| 32 | |
| 33 shouldBe("children.firstElementChild", "first"); | |
| 34 shouldBe("children.lastElementChild", "last"); | |
| 35 shouldBe("first.nextElementSibling", "last"); | |
| 36 shouldBe("first.nextElementSibling.nextElementSibling", "null"); | |
| 37 shouldBe("last.previousElementSibling", "first"); | |
| 38 shouldBe("last.previousElementSibling.previousElementSibling", "null"); | |
| 39 shouldBe("children.childElementCount", "2"); | |
| OLD | NEW |