|
9 | 9 | console.log(this.localName, doc, this.getAttribute('info'));
|
10 | 10 | }
|
11 | 11 | document.register('x-spy', {prototype: proto});
|
| 12 | + |
| 13 | + |
| 14 | + document.addEventListener('DOMContentLoaded', function() { |
| 15 | + var i = document.querySelector('[rel=import]').import; |
| 16 | + var i1 = i.querySelector('[rel=import]').import; |
| 17 | + console.log(i, i1); |
| 18 | + // img path is correct in import but |
| 19 | + // incorrect if cloned and inserted into main document. |
| 20 | + var img = i1.querySelector('img').cloneNode(true);; |
| 21 | + img.src = img.src; |
| 22 | + //var src = img.src; |
| 23 | + document.body.appendChild(img); |
| 24 | + //console.log(img.src); |
| 25 | + |
| 26 | + // if template is cloned and content is inserted into main |
| 27 | + // document, paths are wrong. |
| 28 | + var template = i1.querySelector('template'); |
| 29 | + document.body.appendChild(template.content.cloneNode(true)); |
| 30 | + }); |
12 | 31 | </script>
|
13 | 32 | <link rel="import" href="import1.html">
|
14 | 33 | <link rel="import" href="import2.html">
|
15 | 34 | </head>
|
16 | 35 | <body>
|
| 36 | + <template> |
| 37 | + <link rel="stylesheet" href="css.css"> |
| 38 | + </template> |
17 | 39 | <x-spy info="main-top"></x-spy>
|
18 | 40 | <script>
|
19 | 41 | console.log('script in main');
|
20 | 42 | </script>
|
21 | 43 | <x-spy info="main-bottom"></x-spy>
|
22 |
| - <script> |
23 |
| - var i = document.querySelector('[rel=import]').import; |
24 |
| - var i1 = i.querySelector('[rel=import]').import; |
25 |
| - // img path is correct in import but |
26 |
| - // incorrect if cloned and inserted into main document. |
27 |
| - var img = i1.querySelector('img').cloneNode(true);; |
28 |
| - img.src = img.src; |
29 |
| - //var src = img.src; |
30 |
| - document.body.appendChild(img); |
31 |
| - //console.log(img.src); |
32 |
| - |
33 |
| - // if template is cloned and content is inserted into main |
34 |
| - // document, paths are wrong. |
35 |
| - var template = i1.querySelector('template'); |
36 |
| - document.body.appendChild(template.content.cloneNode(true)); |
37 |
| - </script> |
38 | 44 | </body>
|
39 | 45 | </html>
|
0 commit comments