| OLD | NEW |
| 1 description("This tests element.dataset."); | 1 description("This tests element.dataset."); |
| 2 | 2 |
| 3 function testGet(attr, expected) | 3 function testGet(attr, expected) |
| 4 { | 4 { |
| 5 var d = document.createElement("div"); | 5 var d = document.createElement("div"); |
| 6 d.setAttribute(attr, "value"); | 6 d.setAttribute(attr, "value"); |
| 7 return d.dataset[expected] == "value"; | 7 return d.dataset[expected] == "value"; |
| 8 } | 8 } |
| 9 | 9 |
| 10 shouldBeTrue("testGet('data-foo', 'foo')"); | 10 shouldBeTrue("testGet('data-foo', 'foo')"); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 var d = document.createElement("div"); | 82 var d = document.createElement("div"); |
| 83 d.dataset[prop] = "value"; | 83 d.dataset[prop] = "value"; |
| 84 return d.getAttribute(attr) === null; | 84 return d.getAttribute(attr) === null; |
| 85 } | 85 } |
| 86 | 86 |
| 87 shouldBeTrue("testIsNull('0123', 'data-123')"); | 87 shouldBeTrue("testIsNull('0123', 'data-123')"); |
| 88 shouldBeTrue("testIsNull('123', 'data-0123')"); | 88 shouldBeTrue("testIsNull('123', 'data-0123')"); |
| 89 debug(""); | 89 debug(""); |
| 90 | 90 |
| 91 shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set the \'-foo\
' property on \'DOMStringMap\': \'-foo\' is not a valid property name."'); | 91 shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set the \'-foo\
' property on \'DOMStringMap\': \'-foo\' is not a valid property name."'); |
| 92 shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: \'data-foo\x
20\' is not a valid attribute name."'); | 92 shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: Failed to se
t the \'foo\x20\' property on \'DOMStringMap\': \'data-foo\x20\' is not a valid
attribute name."'); |
| 93 shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: \'data-foo
\uF900\' is not a valid attribute name."'); | 93 shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: Failed to
set the \'foo\uF900\' property on \'DOMStringMap\': \'data-foo\uF900\' is not a
valid attribute name."'); |
| 94 debug(""); | 94 debug(""); |
| 95 | 95 |
| 96 function testDelete(attr, prop) | 96 function testDelete(attr, prop) |
| 97 { | 97 { |
| 98 var d = document.createElement("div"); | 98 var d = document.createElement("div"); |
| 99 d.setAttribute(attr, "value"); | 99 d.setAttribute(attr, "value"); |
| 100 delete d.dataset[prop]; | 100 delete d.dataset[prop]; |
| 101 return d.getAttribute(attr) != "value"; | 101 return d.getAttribute(attr) != "value"; |
| 102 } | 102 } |
| 103 | 103 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 shouldBe("div.getAttribute('data-a-500k')", "'updated'"); | 210 shouldBe("div.getAttribute('data-a-500k')", "'updated'"); |
| 211 | 211 |
| 212 debug(""); | 212 debug(""); |
| 213 debug("Set null:"); | 213 debug("Set null:"); |
| 214 | 214 |
| 215 var d = document.createElement("div"); | 215 var d = document.createElement("div"); |
| 216 d.dataset.foo = null; | 216 d.dataset.foo = null; |
| 217 shouldBe("d.dataset.foo", "'null'"); | 217 shouldBe("d.dataset.foo", "'null'"); |
| 218 | 218 |
| 219 debug(""); | 219 debug(""); |
| OLD | NEW |