| OLD | NEW |
| (Empty) |
| 1 description("Test reflecting boolean attributes."); | |
| 2 | |
| 3 var attributes = [ | |
| 4 [ "area", "noHref" ], | |
| 5 [ "dir", "compact" ], | |
| 6 [ "dl", "compact" ], | |
| 7 [ "form", "noValidate" ], | |
| 8 [ "frame", "noResize" ], | |
| 9 [ "hr", "noShade" ], | |
| 10 [ "iframe", "allowFullscreen" ], | |
| 11 [ "img", "isMap" ], | |
| 12 [ "input", "autofocus" ], | |
| 13 [ "input", "defaultChecked", "checked" ], | |
| 14 [ "input", "disabled" ], | |
| 15 [ "input", "formNoValidate" ], | |
| 16 [ "input", "multiple" ], | |
| 17 [ "input", "readOnly" ], | |
| 18 [ "input", "required" ], | |
| 19 [ "link", "disabled" ], | |
| 20 [ "menu", "compact" ], | |
| 21 [ "menuitem", "checked" ], | |
| 22 [ "menuitem", "default" ], | |
| 23 [ "menuitem", "disabled" ], | |
| 24 [ "object", "declare" ], | |
| 25 [ "ol", "compact" ], | |
| 26 [ "option", "defaultSelected", "selected" ], | |
| 27 [ "script", "defer" ], | |
| 28 [ "select", "multiple" ], | |
| 29 [ "td", "noWrap" ], | |
| 30 [ "ul", "compact" ], | |
| 31 [ "video", "autoplay" ], | |
| 32 [ "video", "controls" ], | |
| 33 [ "video", "loop" ], | |
| 34 ]; | |
| 35 | |
| 36 function make(tag) | |
| 37 { | |
| 38 return document.createElement(tag); | |
| 39 } | |
| 40 | |
| 41 for (var i = 0; i < attributes.length; ++i) { | |
| 42 var tag = attributes[i][0]; | |
| 43 var reflectingAttribute = attributes[i][1]; | |
| 44 var contentAttribute = attributes[i][2] || reflectingAttribute.toLowerCase()
; | |
| 45 shouldBe("e = make('" + tag + "'); " | |
| 46 + "e.removeAttribute('" + contentAttribute + "'); " | |
| 47 + "e." + reflectingAttribute, | |
| 48 "false"); | |
| 49 shouldBe("e = make('" + tag + "'); " | |
| 50 + "e.setAttribute('" + contentAttribute + "', ''); " | |
| 51 + "e." + reflectingAttribute, | |
| 52 "true"); | |
| 53 shouldBe("e = make('" + tag + "'); " | |
| 54 + "e.setAttribute('" + contentAttribute + "', 'x'); " | |
| 55 + "e." + reflectingAttribute + " = false; " | |
| 56 + "e.getAttribute('" + contentAttribute + "')", | |
| 57 "null"); | |
| 58 shouldBe("e = make('" + tag + "'); " | |
| 59 + "e.setAttribute('" + contentAttribute + "', 'x'); " | |
| 60 + "e." + reflectingAttribute + " = true; " | |
| 61 + "e.getAttribute('" + contentAttribute + "')", | |
| 62 "''"); | |
| 63 } | |
| OLD | NEW |