Type of Change
Alignment with specs
Summary
Replace the deprecated Element.prototype.getInnerHTML with Element.prototype.getHTML in dom-shim.js
Details
This issue is in addition to my PR #171
Element.prototype.getInnerHTML has been deprecated in favor of Element.prototype.getHTML (https://developer.mozilla.org/en-US/docs/Web/API/Element/getHTML).
Currently in dom-shim.js, the setter for innerHTML for the HTMLTemplateElement automatically and incorrectly adds a <template> tag with a shadowrootmode attribute to the HTML content of the HTMLTemplateElement itself.
The result is that the innerHTML property of the HTMLTemplateElement will return its HTML contents including the <template> tag which is incorrect and not according to the specs as it should only return its contents without this <template> tag.
Element.prototype.getInnerHTML should be replaced with Element.prototype.getHTML which provides an options argument that enables the serialization of child nodes that are shadow roots:
<section>
<template shadowrootmode="open" shadowrootserializable>
<p>foo</p>
</template>
<p>bar</p>
</section>
section.getHTML();
// returns:
<p>bar</p>
section.getHTML({{serializableShadowRoots: true});
// returns:
<template shadowrootmode="open" shadowrootserializable>
<p>foo</p>
</template>
<p>bar</p>
This also makes sure that Custom Elements that have their shadow roots set through innerHTML can be server-side rendered:
const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.innerHTML = `...`;
Type of Change
Alignment with specs
Summary
Replace the deprecated
Element.prototype.getInnerHTMLwithElement.prototype.getHTMLin dom-shim.jsDetails
This issue is in addition to my PR #171
Element.prototype.getInnerHTMLhas been deprecated in favor ofElement.prototype.getHTML(https://developer.mozilla.org/en-US/docs/Web/API/Element/getHTML).Currently in dom-shim.js, the setter for
innerHTMLfor theHTMLTemplateElementautomatically and incorrectly adds a<template>tag with ashadowrootmodeattribute to the HTML content of theHTMLTemplateElementitself.The result is that the
innerHTMLproperty of theHTMLTemplateElementwill return its HTML contents including the<template>tag which is incorrect and not according to the specs as it should only return its contents without this<template>tag.Element.prototype.getInnerHTMLshould be replaced withElement.prototype.getHTMLwhich provides an options argument that enables the serialization of child nodes that are shadow roots:This also makes sure that Custom Elements that have their shadow roots set through
innerHTMLcan be server-side rendered: