|
11 | 11 | <html>
|
12 | 12 | <head>
|
13 | 13 | <meta charset="utf-8">
|
14 |
| - <script src="../../../webcomponentsjs/webcomponents-lite.js" |
| 14 | + <script src="../../../webcomponentsjs/webcomponents-lite.js" |
15 | 15 | ce="v1" register="true"></script>
|
16 | 16 | <script src="../../../web-component-tester/browser.js"></script>
|
17 | 17 | <script>
|
|
44 | 44 | registerTestElement();
|
45 | 45 | // Create an instance of the test element.
|
46 | 46 | var host = document.createElement('x-content-test');
|
| 47 | + // Populate the initial pool of light DOM children. |
| 48 | + host.innerHTML = hostInnerHtml; |
47 | 49 | document.body.appendChild(host);
|
48 | 50 | CustomElements.takeRecords();
|
| 51 | + // Pretend we're stamping the template contents. |
| 52 | + host.shadyRoot.innerHTML = shadowRootHtml; |
| 53 | + // Invoke distribution and verify the resulting tree. |
| 54 | + ShadyDom.flush(); |
| 55 | + assert.strictEqual(getComposedHTML(host), expectedHtml); |
| 56 | + document.body.removeChild(host); |
| 57 | + }); |
| 58 | + test(descr + ' fragment', function() { |
| 59 | + registerTestElement(); |
| 60 | + // Create an instance of the test element. |
| 61 | + var host = document.createElement('x-content-test'); |
49 | 62 | // Populate the initial pool of light DOM children.
|
50 | 63 | host.innerHTML = hostInnerHtml;
|
| 64 | + document.body.appendChild(host); |
| 65 | + CustomElements.takeRecords(); |
51 | 66 | // Pretend we're stamping the template contents.
|
52 |
| - host.shadyRoot.innerHTML = shadowRootHtml |
| 67 | + var div = document.createElement('div'); |
| 68 | + div.innerHTML = shadowRootHtml; |
| 69 | + var frag = document.createDocumentFragment(); |
| 70 | + while (div.firstChild) { |
| 71 | + frag.appendChild(div.firstChild); |
| 72 | + } |
| 73 | + host.shadyRoot.appendChild(frag); |
53 | 74 | // Invoke distribution and verify the resulting tree.
|
54 | 75 | ShadyDom.flush();
|
55 | 76 | assert.strictEqual(getComposedHTML(host), expectedHtml);
|
|
75 | 96 | testRender('select ""', '<a href="">Link</a> <b>bold</b>',
|
76 | 97 | '<slot></slot>',
|
77 | 98 | '<a href="">Link</a> <b>bold</b>');
|
78 |
| - |
| 99 | + |
79 | 100 | testRender('slot a',
|
80 | 101 | '<a slot="a">a</a> <a slot="b">b</a>',
|
81 | 102 | '<slot name="a"></slot>',
|
|
106 | 127 | host.innerHTML = '<a></a>';
|
107 | 128 | // pre-distirbution grab first composed node.
|
108 | 129 | var a = getComposedChildAtIndex(host, 0);
|
109 |
| - |
| 130 | + |
110 | 131 | host.shadyRoot.innerHTML = '<x-content-test id="p"></x-content-test>';
|
111 | 132 | // force upgrade on polyfilled browsers
|
112 | 133 | var p = host.shadyRoot.firstChild;
|
|
159 | 180 |
|
160 | 181 | test('removeAllChildNodes - mutate host', function() {
|
161 | 182 | host.innerHTML = '<a>Hello</a>';
|
162 |
| - |
| 183 | + |
163 | 184 | host.shadyRoot.innerHTML = '<slot>fallback</slot>';
|
164 | 185 | ShadyDom.flush();
|
165 | 186 | assert.strictEqual(getComposedHTML(host), '<a>Hello</a>');
|
|
176 | 197 |
|
177 | 198 | test('removeAllChildNodes - mutate shadow', function() {
|
178 | 199 | host.innerHTML = '<a>Hello</a>';
|
179 |
| - |
| 200 | + |
180 | 201 | host.shadyRoot.innerHTML = '<slot></slot><b>after</b>';
|
181 | 202 | ShadyDom.flush();
|
182 | 203 | assert.strictEqual(getComposedHTML(host), '<a>Hello</a><b>after</b>');
|
|
192 | 213 |
|
193 | 214 | test('removeAllChildNodes - mutate shadow fallback', function() {
|
194 | 215 | host.innerHTML = '<a>Hello</a>';
|
195 |
| - |
| 216 | + |
196 | 217 | host.shadyRoot.innerHTML = '<slot name="xxx"><b>fallback</b></slot>';
|
197 | 218 | var b = host.shadyRoot.firstChild.firstChild;
|
198 | 219 | ShadyDom.flush();
|
|
213 | 234 |
|
214 | 235 | test('removeChild - mutate host', function() {
|
215 | 236 | host.innerHTML = '<a>Hello</a>';
|
216 |
| - |
| 237 | + |
217 | 238 | host.shadyRoot.innerHTML = '<slot>fallback</slot>';
|
218 | 239 | ShadyDom.flush();
|
219 | 240 | assert.strictEqual(getComposedHTML(host), '<a>Hello</a>');
|
|
247 | 268 |
|
248 | 269 | test('removeChild - mutate shadow', function() {
|
249 | 270 | host.innerHTML = '<a>Hello</a>';
|
250 |
| - |
| 271 | + |
251 | 272 | host.shadyRoot.innerHTML = '<slot></slot><b>after</b>';
|
252 | 273 | var b = host.shadyRoot.lastChild;
|
253 | 274 | ShadyDom.flush();
|
|
269 | 290 | test('setAttribute slot', function() {
|
270 | 291 | host.innerHTML = '<a slot="a">Hello</a><b slot="b">World</b>';
|
271 | 292 |
|
272 |
| - |
| 293 | + |
273 | 294 | host.shadyRoot.innerHTML = '<slot name="b">fallback b</slot>' +
|
274 | 295 | '<slot name="a">fallback a</slot>';
|
275 | 296 | ShadyDom.flush();
|
|
325 | 346 | test('insertBefore - mutate shadow', function() {
|
326 | 347 | host.innerHTML = '<a>Hello</a>';
|
327 | 348 |
|
328 |
| - |
| 349 | + |
329 | 350 | host.shadyRoot.innerHTML = '<slot></slot>';
|
330 | 351 | var content = host.shadyRoot.firstChild;
|
331 | 352 | ShadyDom.flush();
|
|
0 commit comments