shadycss
shadycss copied to clipboard
No output in shadow dom host
I have the following HTML(some details removed for brevity)
<div id="output" class="output">
<shadow-output></shadow-output>
<template id="shadow_contents"></template>
</div>
I am loading the following JS:
webcomponents-hi-sd-ce.js
I then have the following JS
var output = getOutput();
var tmpl = document.getElementById('shadow_contents');
var styleContainer = document.createElement('style');
styleContainer.textContent = output.cssContent;
var htmlContainer = document.createElement('div');
htmlContainer.innerHTML = output.htmlContent;
tmpl.append(styleContainer);
tmpl.append(htmlContainer);
ShadyCSS.prepareTemplate(tmpl, 'shadow-output');
class ShadyOutput extends HTMLElement {
connectedCallback() {
ShadyCSS.styleElement(this);
if (!this.shadowRoot) {
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(
document.importNode(tmpl.content, true)
);
}
}
}
customElements.define('shadow-output', ShadyOutput);
I can see that the elements appended to the template element are present but, nothing is being written to the host i.e. shadow-output
I am sure I am overlooking something but, not sure where things are going wrong.
I think I figured out how this all works :) So, closing this out. There might still be an issue here, that I managed to work around or, not.