|
15 | 15 | var snapshotNodeList = scope.snapshotNodeList;
|
16 | 16 | var unwrap = scope.unwrap;
|
17 | 17 | var wrap = scope.wrap;
|
| 18 | + var wrappers = scope.wrappers; |
18 | 19 |
|
19 | 20 | /////////////////////////////////////////////////////////////////////////////
|
20 | 21 | // innerHTML and outerHTML
|
|
116 | 117 | }
|
117 | 118 |
|
118 | 119 | function getInnerHTML(node) {
|
| 120 | + if (node instanceof wrappers.HTMLTemplateElement) |
| 121 | + node = node.content; |
| 122 | + |
119 | 123 | var s = '';
|
120 | 124 | for (var child = node.firstChild; child; child = child.nextSibling) {
|
121 | 125 | s += getOuterHTML(child, node);
|
|
138 | 142 | var oldIe = /MSIE/.test(navigator.userAgent);
|
139 | 143 |
|
140 | 144 | var OriginalHTMLElement = window.HTMLElement;
|
| 145 | + var OriginalHTMLTemplateElement = window.HTMLTemplateElement; |
141 | 146 |
|
142 | 147 | function HTMLElement(node) {
|
143 | 148 | Element.call(this, node);
|
144 | 149 | }
|
145 | 150 | HTMLElement.prototype = Object.create(Element.prototype);
|
146 | 151 | mixin(HTMLElement.prototype, {
|
147 | 152 | get innerHTML() {
|
148 |
| - // TODO(arv): This should fallback to this.impl.innerHTML if there |
149 |
| - // are no shadow trees below or above the context node. |
150 | 153 | return getInnerHTML(this);
|
151 | 154 | },
|
152 | 155 | set innerHTML(value) {
|
|
163 | 166 |
|
164 | 167 | var removedNodes = snapshotNodeList(this.childNodes);
|
165 | 168 |
|
166 |
| - if (this.invalidateShadowRenderer()) |
167 |
| - setInnerHTML(this, value, this.tagName); |
168 |
| - else |
| 169 | + if (this.invalidateShadowRenderer()) { |
| 170 | + if (this instanceof wrappers.HTMLTemplateElement) |
| 171 | + setInnerHTML(this.content, value); |
| 172 | + else |
| 173 | + setInnerHTML(this, value, this.tagName); |
| 174 | + |
| 175 | + // If we have a non native template element we need to handle this |
| 176 | + // manually since setting impl.innerHTML would add the html as direct |
| 177 | + // children and not be moved over to the content fragment. |
| 178 | + } else if (!OriginalHTMLTemplateElement && |
| 179 | + this instanceof wrappers.HTMLTemplateElement) { |
| 180 | + setInnerHTML(this.content, value); |
| 181 | + } else { |
169 | 182 | this.impl.innerHTML = value;
|
| 183 | + } |
| 184 | + |
170 | 185 | var addedNodes = snapshotNodeList(this.childNodes);
|
171 | 186 |
|
172 | 187 | enqueueMutation(this, 'childList', {
|
|
0 commit comments