blob: 098b677c16e24501e89992d795c8050b5aaabf0a [file] [log] [blame]
This tests element.dataset.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testGet('data-foo', 'foo') is true
PASS testGet('data-foo-bar', 'fooBar') is true
PASS testGet('data--', '-') is true
PASS testGet('data--foo', 'Foo') is true
PASS testGet('data---foo', '-Foo') is true
PASS testGet('data---foo--bar', '-Foo-Bar') is true
PASS testGet('data---foo---bar', '-Foo--Bar') is true
PASS testGet('data-foo-', 'foo-') is true
PASS testGet('data-foo--', 'foo--') is true
PASS testGet('data-Foo', 'foo') is true
PASS testGet('data-', '') is true
PASS testGet('data-à', 'à') is true
PASS document.body.dataset.nonExisting is undefined.
PASS matchesNothingInDataset('dataFoo') is true
PASS testSet('foo', 'data-foo') is true
PASS testSet('fooBar', 'data-foo-bar') is true
PASS testSet('-', 'data--') is true
PASS testSet('Foo', 'data--foo') is true
PASS testSet('-Foo', 'data---foo') is true
PASS testSet('', 'data-') is true
PASS testSet('à', 'data-à') is true
PASS testSet('foo豈', 'data-foo豈') is true
PASS testSet('-foo', 'dummy') threw exception SyntaxError: The string did not match the expected pattern..
PASS testSet('foo ', 'dummy') threw exception InvalidCharacterError: The string contains invalid characters..
PASS testDelete('data-foo', 'foo') is true
PASS testDelete('data-foo-bar', 'fooBar') is true
PASS testDelete('data--', '-') is true
PASS testDelete('data--foo', 'Foo') is true
PASS testDelete('data---foo', '-Foo') is true
PASS testDelete('data-', '') is true
PASS testDelete('data-à', 'à') is true
PASS testDelete('dummy', '-foo') is false
PASS testForIn(['data-foo', 'data-bar', 'data-baz']) is 3
PASS testForIn(['data-foo', 'data-bar', 'dataFoo']) is 2
PASS testForIn(['data-foo', 'data-bar', 'style']) is 2
PASS testForIn(['data-foo', 'data-bar', 'data-']) is 3
Property override:
PASS Object.prototype.foo = 'on Object'; div.dataset.foo is 'on Object'
PASS div.dataset['foo'] = 'on dataset'; div.dataset.foo is 'on dataset'
PASS div.hasAttribute('data-foo') is true
PASS div.setAttribute('data-foo', 'attr'); div.dataset.foo is 'attr'
Update the JavaScript property:
PASS div.dataset.foo = 'updated'; div.dataset.foo is 'updated'
PASS div.getAttribute('data-foo') is 'updated'
PASS div.dataset.Bar = 'on dataset'; div.dataset.Bar is 'on dataset'
PASS div.hasAttribute('data-Bar') is false
Make the JavaScript property empty:
PASS div.dataset.foo = ''; div.dataset.foo is ''
PASS div.getAttribute('data-foo') is ''
Remove the attribute:
PASS div.removeAttribute('data-foo'); div.dataset.foo is 'on Object'
Remove the JavaScript property:
PASS div.setAttribute('data-foo', 'attr'); delete div.dataset.foo; div.dataset.foo is 'on Object'
PASS div.hasAttribute('foo') is false
PASS delete div.dataset.Bar; div.dataset.Bar is undefined.
PASS successfullyParsed is true
TEST COMPLETE