4 <title>HTML Templates: Clone template node: All the children of template content are copied if 'copy children flag' set to true</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="Clone template node: all the children of template content are copied if 'copy children flag' set to true">
7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#node-clone-additions">
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">
15 <script type="text/javascript">
18 var doc = newHTMLDocument();
19 doc.body.innerHTML = '<template id="tmpl1">' +
20 '<div id="div1">This is div inside template</div>' +
21 '<div id="div2">This is another div inside template</div>' +
24 var template = doc.querySelector('#tmpl1');
25 var copy = template.cloneNode(true);
27 assert_not_equals(copy.content, undefined, 'Template clone content attribute should not be undefined');
28 assert_not_equals(copy.content, null, 'Template clone content attribute should not be null');
30 assert_equals(copy.content.childNodes.length, 2,
31 'Wrong number of template content\'s copy child nodes');
32 assert_not_equals(copy.content.querySelector('#div1'), null,
33 'Template child node should be copied');
34 assert_not_equals(copy.content.querySelector('#div2'), null,
35 'Template child node should be copied');
37 }, 'Clone template node. Test call to cloneNode(true)');
42 var doc = newHTMLDocument();
43 doc.body.innerHTML = '<template id="tmpl1">' +
44 '<div id="div1">This is div inside template</div>' +
45 '<div id="div2">This is another div inside template</div>' +
48 var template = doc.querySelector('#tmpl1');
49 var copy = template.cloneNode();
51 assert_not_equals(copy.content, undefined, 'Template clone content attribute should not be undefined');
52 assert_not_equals(copy.content, null, 'Template clone content attribute should not be null');
54 assert_equals(copy.content.childNodes.length, 0,
55 'Wrong number of template content\'s copy child nodes');
57 }, 'Clone template node. Test call to cloneNode() with the default parameter '
58 + '(false by default)');
63 var doc = newHTMLDocument();
64 doc.body.innerHTML = '<template id="tmpl1">' +
65 '<div id="div1">This is div inside template</div>' +
66 '<div id="div2">This is another div inside template</div>' +
69 var template = doc.querySelector('#tmpl1');
70 var copy = template.cloneNode(false);
72 assert_not_equals(copy.content, undefined, 'Template clone content attribute is undefined');
73 assert_not_equals(copy.content, null, 'Template clone content attribute is null');
75 assert_equals(copy.content.childNodes.length, 0,
76 'Wrong number of template content\'s copy child nodes');
78 }, 'Clone template node. Test call to cloneNode(false)');