| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 shouldBeTrue("testSet('foo', 'data-foo')"); | 46 shouldBeTrue("testSet('foo', 'data-foo')"); |
| 47 shouldBeTrue("testSet('fooBar', 'data-foo-bar')"); | 47 shouldBeTrue("testSet('fooBar', 'data-foo-bar')"); |
| 48 shouldBeTrue("testSet('-', 'data--')"); | 48 shouldBeTrue("testSet('-', 'data--')"); |
| 49 shouldBeTrue("testSet('Foo', 'data--foo')"); | 49 shouldBeTrue("testSet('Foo', 'data--foo')"); |
| 50 shouldBeTrue("testSet('-Foo', 'data---foo')"); | 50 shouldBeTrue("testSet('-Foo', 'data---foo')"); |
| 51 shouldBeTrue("testSet('', 'data-')"); | 51 shouldBeTrue("testSet('', 'data-')"); |
| 52 shouldBeTrue("testSet('\xE0', 'data-\xE0')"); | 52 shouldBeTrue("testSet('\xE0', 'data-\xE0')"); |
| 53 debug(""); | 53 debug(""); |
| 54 | 54 |
| 55 shouldThrow("testSet('-foo', 'dummy')", "'Error: SyntaxError: DOM Exception 12'"
); | 55 shouldThrow("testSet('-foo', 'dummy')", "'SyntaxError: An invalid or illegal str
ing was specified.'"); |
| 56 shouldThrow("testSet('foo\x20', 'dummy')", "'Error: InvalidCharacterError: DOM E
xception 5'"); | 56 shouldThrow("testSet('foo\x20', 'dummy')", "'InvalidCharacterError: An invalid o
r illegal character was specified, such as in an XML name.'"); |
| 57 shouldThrow("testSet('foo\uF900', 'dummy')", "'Error: InvalidCharacterError: DOM
Exception 5'"); | 57 shouldThrow("testSet('foo\uF900', 'dummy')", "'InvalidCharacterError: An invalid
or illegal character was specified, such as in an XML name.'"); |
| 58 debug(""); | 58 debug(""); |
| 59 | 59 |
| 60 function testDelete(attr, prop) | 60 function testDelete(attr, prop) |
| 61 { | 61 { |
| 62 var d = document.createElement("div"); | 62 var d = document.createElement("div"); |
| 63 d.setAttribute(attr, "value"); | 63 d.setAttribute(attr, "value"); |
| 64 delete d.dataset[prop]; | 64 delete d.dataset[prop]; |
| 65 return d.getAttribute(attr) != "value"; | 65 return d.getAttribute(attr) != "value"; |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 shouldBeUndefined("delete div.dataset.Bar; div.dataset.Bar"); | 123 shouldBeUndefined("delete div.dataset.Bar; div.dataset.Bar"); |
| 124 | 124 |
| 125 debug(""); | 125 debug(""); |
| 126 debug("Set null:"); | 126 debug("Set null:"); |
| 127 | 127 |
| 128 var d = document.createElement("div"); | 128 var d = document.createElement("div"); |
| 129 d.dataset.foo = null; | 129 d.dataset.foo = null; |
| 130 shouldBe("d.dataset.foo", "'null'"); | 130 shouldBe("d.dataset.foo", "'null'"); |
| 131 | 131 |
| 132 debug(""); | 132 debug(""); |
| OLD | NEW |