|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <script src="../testing.js"></script> |
3 | 3 |
|
4 | | -<div id="content"> |
| 4 | +<div id="content" dir="ltr"> |
5 | 5 | <a id="link" href="foo" class="ok">OK</a> |
6 | 6 | <p id="para-empty" class="ok empty"> |
7 | 7 | <span id="para-empty-child"></span> |
|
17 | 17 | testing.expectEqual('div', content.localName); |
18 | 18 | testing.expectEqual('DIV', content.tagName); |
19 | 19 | testing.expectEqual('content', content.id); |
| 20 | + testing.expectEqual('ltr', content.dir); |
20 | 21 |
|
21 | 22 | content.id = 'foo'; |
22 | 23 | testing.expectEqual('foo', content.id); |
|
26 | 27 |
|
27 | 28 | let p1 = document.getElementById('para-empty'); |
28 | 29 | testing.expectEqual('ok empty', p1.className); |
| 30 | + testing.expectEqual('', p1.dir); |
29 | 31 |
|
30 | 32 | p1.className = 'foo bar baz'; |
31 | 33 | testing.expectEqual('foo bar baz', p1.className); |
|
52 | 54 |
|
53 | 55 | <script id=attributes> |
54 | 56 | testing.expectEqual(true, content.hasAttributes()); |
55 | | - testing.expectEqual(1, content.attributes.length); |
56 | | - testing.expectEqual(['id'], content.getAttributeNames()); |
| 57 | + testing.expectEqual(2, content.attributes.length); |
| 58 | + testing.expectEqual(['id', 'dir'], content.getAttributeNames()); |
57 | 59 | testing.expectEqual('content', content.getAttribute('id')); |
58 | 60 | testing.expectEqual('content', content.attributes['id'].value); |
59 | 61 |
|
60 | 62 | let x = ''; |
61 | 63 | for (const attr of content.attributes) { |
62 | | - x += attr.name + '=' + attr.value; |
| 64 | + x += attr.name + '=' + attr.value + ','; |
63 | 65 | } |
64 | | - testing.expectEqual('id=content', x); |
| 66 | + testing.expectEqual('id=content,dir=ltr,', x); |
65 | 67 |
|
66 | 68 | testing.expectEqual(false, content.hasAttribute('foo')); |
67 | 69 | testing.expectEqual(null, content.getAttribute('foo')); |
68 | 70 |
|
69 | 71 | content.setAttribute('foo', 'bar'); |
70 | 72 | testing.expectEqual(true, content.hasAttribute('foo')); |
71 | 73 | testing.expectEqual('bar', content.getAttribute('foo')); |
72 | | - testing.expectEqual(['id', 'foo'], content.getAttributeNames()); |
| 74 | + testing.expectEqual(['id', 'dir', 'foo'], content.getAttributeNames()); |
73 | 75 |
|
74 | 76 | testing.expectError('Error: InvalidCharacterError', () => { |
75 | 77 | content.setAttribute('.foo', 'invalid') |
|
263 | 265 | $('#to-remove').remove(); |
264 | 266 | testing.expectEqual(null, $('#to-remove')); |
265 | 267 | </script> |
| 268 | + |
| 269 | +<script id=elementDir> |
| 270 | + const divElement = document.createElement("div"); |
| 271 | + // Always initialized with empty string if `dir` attribute not provided. |
| 272 | + testing.expectEqual("", divElement.dir); |
| 273 | + |
| 274 | + divElement.dir = "ltr"; |
| 275 | + testing.expectEqual("ltr", divElement.dir); |
| 276 | + |
| 277 | + divElement.dir = "rtl"; |
| 278 | + testing.expectEqual("rtl", divElement.dir); |
| 279 | + |
| 280 | + divElement.dir = "auto"; |
| 281 | + testing.expectEqual("auto", divElement.dir); |
| 282 | +</script> |
0 commit comments