| OLD | NEW |
| 1 description("This tests element.dataset for XHTML."); | 1 description("This tests element.dataset for XHTML."); |
| 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 30 matching lines...) Expand all Loading... |
| 41 shouldBeTrue("testSet('foo', 'data-foo')"); | 41 shouldBeTrue("testSet('foo', 'data-foo')"); |
| 42 shouldBeTrue("testSet('fooBar', 'data-foo-bar')"); | 42 shouldBeTrue("testSet('fooBar', 'data-foo-bar')"); |
| 43 shouldBeTrue("testSet('-', 'data--')"); | 43 shouldBeTrue("testSet('-', 'data--')"); |
| 44 shouldBeTrue("testSet('Foo', 'data--foo')"); | 44 shouldBeTrue("testSet('Foo', 'data--foo')"); |
| 45 shouldBeTrue("testSet('-Foo', 'data---foo')"); | 45 shouldBeTrue("testSet('-Foo', 'data---foo')"); |
| 46 shouldBeTrue("testSet('', 'data-')"); | 46 shouldBeTrue("testSet('', 'data-')"); |
| 47 shouldBeTrue("testSet('\xE0', 'data-\xE0')"); | 47 shouldBeTrue("testSet('\xE0', 'data-\xE0')"); |
| 48 debug(""); | 48 debug(""); |
| 49 | 49 |
| 50 shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set the \'-foo\
' property on \'DOMStringMap\': \'-foo\' is not a valid property name."'); | 50 shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set the \'-foo\
' property on \'DOMStringMap\': \'-foo\' is not a valid property name."'); |
| 51 shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: \'data-foo\x
20\' is not a valid attribute name."'); | 51 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."'); |
| 52 shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: \'data-foo
\uF900\' is not a valid attribute name."'); | 52 shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: Failed to
set the \'foo\uF900\' property on \'DOMStringMap\': \'data-foo\uF900\' is not a
valid attribute name."'); |
| 53 debug(""); | 53 debug(""); |
| 54 | 54 |
| 55 function testDelete(attr, prop) | 55 function testDelete(attr, prop) |
| 56 { | 56 { |
| 57 var d = document.createElement("div"); | 57 var d = document.createElement("div"); |
| 58 d.setAttribute(attr, "value"); | 58 d.setAttribute(attr, "value"); |
| 59 delete d.dataset[prop]; | 59 delete d.dataset[prop]; |
| 60 return d.getAttribute(attr) != "value"; | 60 return d.getAttribute(attr) != "value"; |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 83 for (var item in d.dataset) | 83 for (var item in d.dataset) |
| 84 count++; | 84 count++; |
| 85 | 85 |
| 86 return count; | 86 return count; |
| 87 } | 87 } |
| 88 | 88 |
| 89 shouldBe("testForIn(['data-foo', 'data-bar', 'data-baz'])", "3"); | 89 shouldBe("testForIn(['data-foo', 'data-bar', 'data-baz'])", "3"); |
| 90 shouldBe("testForIn(['data-foo', 'data-bar', 'dataFoo'])", "2"); | 90 shouldBe("testForIn(['data-foo', 'data-bar', 'dataFoo'])", "2"); |
| 91 shouldBe("testForIn(['data-foo', 'data-bar', 'style'])", "2"); | 91 shouldBe("testForIn(['data-foo', 'data-bar', 'style'])", "2"); |
| 92 shouldBe("testForIn(['data-foo', 'data-bar', 'data-'])", "3"); | 92 shouldBe("testForIn(['data-foo', 'data-bar', 'data-'])", "3"); |
| OLD | NEW |