|
113 | 113 | assert_true(!!host.shadowRoot,"No shadow root found");
|
114 | 114 | assert_false(host.shadowRoot.delegatesFocus,"delegatesFocus should be false without the shadowrootdelegatesfocus attribute");
|
115 | 115 | }, 'Declarative Shadow DOM: delegates focus attribute');
|
| 116 | + |
| 117 | +test(() => { |
| 118 | + const host = document.createElement('div'); |
| 119 | + // Root element of innerHTML is a <template shadowroot>: |
| 120 | + host.innerHTML = '<template shadowroot=open></template>'; |
| 121 | + assert_equals(host.shadowRoot, null, "Shadow root should not be present"); |
| 122 | + const tmpl = host.querySelector('template'); |
| 123 | + assert_true(!!tmpl,"Template should still be present"); |
| 124 | + assert_equals(tmpl.getAttribute('shadowroot'),"open","'shadowroot' attribute should still be present"); |
| 125 | +}, 'Declarative Shadow DOM: innerHTML root element'); |
116 | 126 | </script>
|
117 | 127 |
|
118 | 128 | <div id="multi-host">
|
|
123 | 133 | <span>root 2</span>
|
124 | 134 | </template>
|
125 | 135 | </div>
|
126 |
| - |
127 | 136 | <script>
|
128 | 137 | test(() => {
|
129 | 138 | const host = document.querySelector('#multi-host');
|
|
134 | 143 | }, 'Declarative Shadow DOM: Multiple roots');
|
135 | 144 |
|
136 | 145 | </script>
|
| 146 | + |
| 147 | +<template id="root-element-shadow"> |
| 148 | + <template shadowroot=open>Content</template> |
| 149 | +</template> |
| 150 | +<script> |
| 151 | +test(() => { |
| 152 | + // Root element of this template is a <template shadowroot>: |
| 153 | + const template = document.querySelector('#root-element-shadow'); |
| 154 | + const host = document.createElement('div'); |
| 155 | + host.appendChild(template.content.cloneNode(true)); |
| 156 | + assert_equals(host.shadowRoot, null, "Shadow root should not be present"); |
| 157 | + const tmpl = host.querySelector('template'); |
| 158 | + assert_true(!!tmpl,"Template should still be present"); |
| 159 | + assert_equals(tmpl.getAttribute('shadowroot'),"open","'shadowroot' attribute should still be present"); |
| 160 | +}, 'Declarative Shadow DOM: template root element'); |
| 161 | +</script> |
0 commit comments