OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>HTML Templates: serialize template contents instead of template element</
title> |
| 5 <meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru"> |
| 6 <meta name="assert" content="template contents should be serialized instead of t
emplate element if serializing template element"> |
| 7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#ser
ializing-html-templates"> |
| 8 <script src="../../../../../../../resources/testharness.js"></script> |
| 9 <script src="../../../../../../../resources/testharnessreport.js"></script> |
| 10 <script src='../testcommon.js'></script> |
| 11 <link rel="stylesheet" href="../../../../../../../resources/testharness.css"> |
| 12 </head> |
| 13 <body> |
| 14 <div id="log"></div> |
| 15 <script type="text/javascript"> |
| 16 |
| 17 test(function () { |
| 18 var doc = newHTMLDocument(); |
| 19 var template = doc.createElement('template'); |
| 20 |
| 21 var div = doc.createElement('div'); |
| 22 div.setAttribute('id', 'div1'); |
| 23 div.innerHTML = 'some text'; |
| 24 template.content.appendChild(div); |
| 25 |
| 26 assert_equals(template.outerHTML, '<template><div id="div1">some text</div><
/template>', |
| 27 'template element is serialized incorrectly'); |
| 28 |
| 29 }, 'Template contents should be serialized instead of template element if serial
izing template element'); |
| 30 |
| 31 |
| 32 |
| 33 test(function () { |
| 34 var doc = newHTMLDocument(); |
| 35 var template = doc.createElement('template'); |
| 36 var nestedTemplate = doc.createElement('template'); |
| 37 |
| 38 template.content.appendChild(nestedTemplate); |
| 39 |
| 40 var div = doc.createElement('div'); |
| 41 div.setAttribute('id', 'div1'); |
| 42 div.innerHTML = 'some text'; |
| 43 nestedTemplate.content.appendChild(div); |
| 44 |
| 45 assert_equals(template.outerHTML, '<template><template><div id="div1">some t
ext</div></template></template>', |
| 46 'template element is serialized incorrectly'); |
| 47 |
| 48 |
| 49 }, 'Template contents should be serialized instead of template element if serial
izing template element. ' |
| 50 + 'Test nested template'); |
| 51 |
| 52 |
| 53 test(function () { |
| 54 var doc = newHTMLDocument(); |
| 55 var template = doc.createElement('template'); |
| 56 |
| 57 var div = doc.createElement('div'); |
| 58 div.setAttribute('id', 'div1'); |
| 59 div.innerHTML = 'some text'; |
| 60 template.content.appendChild(div); |
| 61 doc.body.appendChild(template); |
| 62 |
| 63 assert_equals(doc.documentElement.outerHTML, '<html><head><title>Test Docume
nt</title></head><body><template><div id="div1">some text</div></template></body
></html>', |
| 64 'template element is serialized incorrectly'); |
| 65 |
| 66 }, 'Template contents should be serialized instead of template element if serial
izing template element. ' |
| 67 + 'Test serializing whole document'); |
| 68 |
| 69 </script> |
| 70 </body> |
| 71 </html> |
OLD | NEW |