| 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 <p>Microdata properties collection must update on adding or removing property.</
p> | |
| 9 <div itemprop="foo" id="test"> | |
| 10 </div> | |
| 11 <div itemscope id="microdata-item"> | |
| 12 <p itemprop="foo"></p> | |
| 13 </div> | |
| 14 <div id="console"></div> | |
| 15 <script> | |
| 16 var item = document.getElementById('microdata-item'); | |
| 17 var propertyNodeList = item.properties.namedItem('foo'); | |
| 18 var testElement = document.getElementById('test'); | |
| 19 | |
| 20 shouldBeTrue("propertyNodeList.length == '1'"); | |
| 21 shouldBeTrue("propertyNodeList[0] == item.children[0]"); | |
| 22 | |
| 23 debug('Add a property to the item.'); | |
| 24 item.appendChild(createElement('div', {itemprop: 'foo'})); | |
| 25 shouldBeTrue("propertyNodeList.length == 2"); | |
| 26 shouldBeTrue("propertyNodeList[0] == item.children[0]"); | |
| 27 shouldBeTrue("propertyNodeList[1] == item.children[1]"); | |
| 28 | |
| 29 debug('Remove itemprop attribute of the first child.'); | |
| 30 item.children[0].removeAttribute('itemprop'); | |
| 31 shouldBeTrue("propertyNodeList.length == 1"); | |
| 32 shouldBeTrue("propertyNodeList[0] == item.children[1]"); | |
| 33 | |
| 34 debug('Add itemprop attribute to the first child.'); | |
| 35 item.children[0].setAttribute('itemprop', 'foo'); | |
| 36 shouldBeTrue("propertyNodeList.length == 2"); | |
| 37 shouldBeTrue("propertyNodeList[0] == item.children[0]"); | |
| 38 shouldBeTrue("propertyNodeList[1] == item.children[1]"); | |
| 39 | |
| 40 debug('Add itemref attribute.'); | |
| 41 item.setAttribute('itemref', 'test'); | |
| 42 shouldBeTrue("propertyNodeList.length == 3"); | |
| 43 shouldBeTrue("propertyNodeList[0] == testElement"); | |
| 44 shouldBeTrue("propertyNodeList[1] == item.children[0]"); | |
| 45 shouldBeTrue("propertyNodeList[2] == item.children[1]"); | |
| 46 | |
| 47 debug('Remove itemref attribute.'); | |
| 48 item.removeAttribute('itemref'); | |
| 49 shouldBeTrue("propertyNodeList.length == 2"); | |
| 50 shouldBeTrue("propertyNodeList[0] == item.children[0]"); | |
| 51 shouldBeTrue("propertyNodeList[1] == item.children[1]"); | |
| 52 | |
| 53 debug('Add itemref attribute.'); | |
| 54 item.setAttribute('itemref', 'test'); | |
| 55 shouldBeTrue("propertyNodeList.length == 3"); | |
| 56 shouldBeTrue("propertyNodeList[0] == testElement"); | |
| 57 shouldBeTrue("propertyNodeList[1] == item.children[0]"); | |
| 58 shouldBeTrue("propertyNodeList[2] == item.children[1]"); | |
| 59 </script> | |
| 60 <script src="../../js/resources/js-test-post.js"></script> | |
| 61 </body> | |
| 62 </html> | |
| 63 | |
| OLD | NEW |