| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../js/resources/js-test-pre.js"></script> | |
| 5 <script src="resources/microdata-common.js"></script> | |
| 6 </head> | |
| 7 <body> | |
| 8 <script> | |
| 9 description("Test to ensure that modifing properties of an item which is not att
ached to the DOM tree must update its HTMLPropertiesCollection."); | |
| 10 var parent = createElement('div', {}, '<div itemprop="foo" id="id1"></div><div i
temscope><div itemprop="bar"></div></div>'); | |
| 11 var item = parent.childNodes[1]; | |
| 12 | |
| 13 shouldBe("item.properties.length", "1"); | |
| 14 shouldBe("item.properties.item(0)", "item.firstChild"); | |
| 15 shouldBe("item.properties[0]", "item.firstChild"); | |
| 16 | |
| 17 debug(""); | |
| 18 debug("Add properties through itemref attribute."); | |
| 19 item.setAttribute("itemref", "id1"); | |
| 20 shouldBe("item.properties.length", "2"); | |
| 21 shouldBe("item.properties.item(0)", "parent.firstChild"); | |
| 22 shouldBe("item.properties[0]", "parent.firstChild"); | |
| 23 shouldBe("item.properties.item(1)", "item.firstChild"); | |
| 24 shouldBe("item.properties[1]", "item.firstChild"); | |
| 25 | |
| 26 debug(""); | |
| 27 debug("Add property to ref element"); | |
| 28 parent.firstChild.appendChild(createElement('div', {itemprop: 'qux'})); | |
| 29 shouldBe("item.properties.length", "3"); | |
| 30 shouldBe("item.properties.item(0)", "parent.firstChild"); | |
| 31 shouldBe("item.properties[0]", "parent.firstChild"); | |
| 32 shouldBe("item.properties.item(1)", "parent.firstChild.firstChild"); | |
| 33 shouldBe("item.properties[1]", "parent.firstChild.firstChild"); | |
| 34 shouldBe("item.properties.item(2)", "item.firstChild"); | |
| 35 shouldBe("item.properties[2]", "item.firstChild"); | |
| 36 | |
| 37 debug(""); | |
| 38 debug("Add properties direct to the item"); | |
| 39 item.appendChild(createElement('div', {itemprop: 'baz'})); | |
| 40 shouldBe("item.properties.length", "4"); | |
| 41 shouldBe("item.properties.item(3)", "item.childNodes[1]"); | |
| 42 shouldBe("item.properties[3]", "item.childNodes[1]"); | |
| 43 | |
| 44 debug(""); | |
| 45 debug("Remove property"); | |
| 46 item.removeChild(item.lastChild); | |
| 47 shouldBe("item.properties.length", "3"); | |
| 48 shouldBeNull("item.properties.item(3)"); | |
| 49 shouldBeUndefined("item.properties[3]"); | |
| 50 | |
| 51 debug(""); | |
| 52 debug("Remove property from ref element"); | |
| 53 parent.firstChild.removeChild(parent.firstChild.firstChild); | |
| 54 shouldBe("item.properties.length", "2"); | |
| 55 shouldBe("item.properties.item(0)", "parent.firstChild"); | |
| 56 shouldBe("item.properties[0]", "parent.firstChild"); | |
| 57 shouldBe("item.properties.item(1)", "item.firstChild"); | |
| 58 shouldBe("item.properties[1]", "item.firstChild"); | |
| 59 | |
| 60 debug(""); | |
| 61 debug("Remove property added through itemref"); | |
| 62 item.removeAttribute("itemref"); | |
| 63 shouldBe("item.properties.length", "1"); | |
| 64 shouldBe("item.properties.item(0)", "item.firstChild"); | |
| 65 shouldBe("item.properties[0]", "item.firstChild"); | |
| 66 </script> | |
| 67 <script src="../../js/resources/js-test-post.js"></script> | |
| 68 </body> | |
| 69 </html> | |
| OLD | NEW |