OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>HTML Templates: Child nodes of template element in XHTML documents</title
> |
| 5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 6 <meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru"> |
| 7 <meta name="assert" content="Child nodes of template element in XHTML documents
are always appended to the template content (instead of template itself)"> |
| 8 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#par
sing-xhtml-documents"> |
| 9 <script src="../../../../../../../resources/testharness.js"></script> |
| 10 <script src="../../../../../../../resources/testharnessreport.js"></script> |
| 11 <script src='../testcommon.js'></script> |
| 12 <link rel="stylesheet" href="../../../../../../../resources/testharness.css"> |
| 13 </head> |
| 14 <body> |
| 15 <div id="log"></div> |
| 16 <script type="text/javascript"> |
| 17 |
| 18 |
| 19 test(function() { |
| 20 var doc = newXHTMLDocument(); |
| 21 |
| 22 doc.body = doc.createElement('body'); |
| 23 doc.body.innerHTML = '<template id="tmpl1">' |
| 24 + '<div id="div1">This is div inside template</div>' |
| 25 + '<div id="div2">This is another div inside template</div>' |
| 26 + '</template>'; |
| 27 |
| 28 var template = doc.querySelector('#tmpl1'); |
| 29 |
| 30 assert_equals(template.childNodes.length, 0, |
| 31 'Wrong number of template child nodes'); |
| 32 assert_equals(template.content.childNodes.length, 2, |
| 33 'Wrong number of template content child nodes'); |
| 34 |
| 35 }, 'Child nodes of template element in XHTML documents must be appended to templ
ate content'); |
| 36 |
| 37 |
| 38 |
| 39 test(function() { |
| 40 var doc = newXHTMLDocument(); |
| 41 doc.body = doc.createElement('body'); |
| 42 doc.body.innerHTML = '<template id="tmpl1">' |
| 43 + '<div id="div1">This is div inside template</div>' |
| 44 + '<div id="div2">This is another div inside template</div>' |
| 45 + '<template id="tmpl2">' |
| 46 + '<div id="div3">This is div inside nested template</div>' |
| 47 + '<div id="div4">This is another div inside nested template</div>' |
| 48 + '</template>' + '</template>'; |
| 49 |
| 50 var template = doc.querySelector('#tmpl1'); |
| 51 |
| 52 assert_equals(template.childNodes.length, 0, |
| 53 'Wrong number of template child nodes'); |
| 54 assert_equals(template.content.childNodes.length, 3, |
| 55 'Wrong number of template content child nodes'); |
| 56 |
| 57 var nestedTemplate = template.content.querySelector('#tmpl2'); |
| 58 |
| 59 assert_equals(nestedTemplate.childNodes.length, 0, |
| 60 'Wrong number of template child nodes'); |
| 61 assert_equals(nestedTemplate.content.childNodes.length, 2, |
| 62 'Wrong number of nested template content child nodes'); |
| 63 |
| 64 }, 'Child nodes of nested template element in XHTML documents must be appended t
o template content'); |
| 65 |
| 66 |
| 67 |
| 68 testInIFrame('../resources/template-child-nodes-div.xhtml', function(context) { |
| 69 var doc = context.iframes[0].contentDocument; |
| 70 |
| 71 var template = doc.querySelector('template'); |
| 72 |
| 73 assert_equals(template.childNodes.length, 0, |
| 74 'Wrong number of template child nodes'); |
| 75 assert_equals(template.content.querySelectorAll('div').length, 2, |
| 76 'Wrong number of template content child nodes'); |
| 77 |
| 78 }, 'Child nodes of template element in XHTML documents must be appended to templ
ate content. ' |
| 79 + 'Test loading XHTML document from a file'); |
| 80 |
| 81 |
| 82 testInIFrame('../resources/template-child-nodes-nested.xhtml', function(context)
{ |
| 83 var doc = context.iframes[0].contentDocument; |
| 84 |
| 85 var template = doc.querySelector('template'); |
| 86 |
| 87 assert_equals(template.childNodes.length, 0, |
| 88 'Wrong number of template child nodes'); |
| 89 |
| 90 var nestedTemplate = template.content.querySelector('template'); |
| 91 |
| 92 assert_equals(nestedTemplate.childNodes.length, 0, |
| 93 'Wrong number of template child nodes'); |
| 94 |
| 95 assert_equals(nestedTemplate.content.querySelectorAll('div').length, 2, |
| 96 'Wrong number of template content child nodes'); |
| 97 |
| 98 }, 'Child nodes of nested template element in XHTML documents must be appended t
o template content. ' |
| 99 + 'Test loading XHTML document from a file'); |
| 100 |
| 101 </script> |
| 102 </body> |
| 103 </html> |
OLD | NEW |