OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset=utf-8> | 4 <meta charset=utf-8> |
5 <title>HTML time element API</title> | 5 <title>HTML time element API</title> |
6 <style> | 6 <style> |
7 #time { visibility: hidden; } | 7 #time { visibility: hidden; } |
8 </style> | 8 </style> |
9 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-time-elem
ent"> | 9 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-time-elem
ent"> |
10 <script src="/resources/testharness.js"></script> | 10 <script src="/resources/testharness.js"></script> |
11 <script src="/resources/testharnessreport.js"></script> | 11 <script src="/resources/testharnessreport.js"></script> |
12 </head> | 12 </head> |
13 <body> | 13 <body> |
14 <div id="log"></div> | 14 <div id="log"></div> |
15 <!-- intentionally nested to test parsing rules --> | 15 <!-- intentionally nested to test parsing rules --> |
16 <p id="time"><time pubdate datetime="2000-02-01T03:04:05Z">Dummy text <time>
2001-06-07T<time>08:09<time></time></time>Z</time></time></p> | 16 <p id="time"><time pubdate datetime="2000-02-01T03:04:05Z">Dummy text <time>
2001-06-07T<time>08:09<time></time></time>Z</time></time></p> |
17 <script type="text/javascript"> | 17 <script type="text/javascript"> |
18 function makeTime(dateTime,contents,dateTimeProp) { | 18 function makeTime(dateTime,contents,dateTimeProp) { |
19 var timeEl = document.createElement('time'); | 19 var timeEl = document.createElement('time'); |
20 if( dateTime ) { | 20 if( dateTime ) { |
21 timeEl.setAttribute('datetime',dateTime); | 21 timeEl.setAttribute('datetime',dateTime); |
22 } | 22 } |
23 if( contents ) { | 23 if( contents ) { |
24 timeEl.innerHTML = contents; | 24 timeEl.innerHTML = contents; |
25 } | 25 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 assert_equals( makeTime('go fish').dateTime, 'go fish' ); | 59 assert_equals( makeTime('go fish').dateTime, 'go fish' ); |
60 }, 'the datetime attribute should be reflected by the .dateTime property even if
it is invalid'); | 60 }, 'the datetime attribute should be reflected by the .dateTime property even if
it is invalid'); |
61 test(function () { | 61 test(function () { |
62 assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '' ); | 62 assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '' ); |
63 }, 'the datetime attribute should not reflect the textContent'); | 63 }, 'the datetime attribute should not reflect the textContent'); |
64 | 64 |
65 </script> | 65 </script> |
66 | 66 |
67 </body> | 67 </body> |
68 </html> | 68 </html> |
OLD | NEW |