src/webComponentBaseClass.js
function createShadowDOM(p_ComponentInstance, p_ComponentTemplate) {
	// retrieve the correct template from our map of previously stored templates
	const templateInstance = window.webComponentTemplates.get(p_ComponentTemplate);
	// if we are using the shadyCSS polyfill, we must initialize that now
	if (window.ShadyCSS) {
		window.ShadyCSS.prepareTemplate(templateInstance, p_ComponentTemplate);
		window.ShadyCSS.styleElement(p_ComponentInstance);
	}

	// create the shadow DOM root here
	const shadowRoot = p_ComponentInstance.attachShadow({ mode: 'open' });
	shadowRoot.appendChild(templateInstance.content.cloneNode(true));
}
function createShadowDOM(p_ComponentInstance, p_ComponentTemplate) {
	// retrieve the correct template from our map of previously stored templates
	const templateInstance = window.webComponentTemplates.get(p_ComponentTemplate);
	// if we are using the shadyCSS polyfill, we must initialize that now
	if (window.ShadyCSS) {
		window.ShadyCSS.prepareTemplate(templateInstance, p_ComponentTemplate);
		window.ShadyCSS.styleElement(p_ComponentInstance);
	}

	// create the shadow DOM root here
	const shadowRoot = p_ComponentInstance.attachShadow({ mode: 'open' });
	shadowRoot.appendChild(templateInstance.content.cloneNode(true));
}
function createShadowDOM ( p_ComponentInstance , p_ComponentTemplate ) { // retrieve the correct template from our map of previously stored templates const templateInstance = window . webComponentTemplates . get ( p_ComponentTemplate ) ; // if we are using the shadyCSS polyfill, we must initialize that now if ( window . ShadyCSS ) { window . ShadyCSS . prepareTemplate ( templateInstance , p_ComponentTemplate ) ; window . ShadyCSS . styleElement ( p_ComponentInstance ) ; } // create the shadow DOM root here const shadowRoot = p_ComponentInstance . attachShadow ( { mode : 'open' } ) ; shadowRoot . appendChild ( templateInstance . content . cloneNode ( true ) ) ; }
Create the shadow DOM and attach it to the given web component instance
@param {HTMLElement} p_ComponentInstance The web component instance to which we are attaching the shadow DOM
@param {string} p_ComponentTemplate The id of the web component template
Create the shadow DOM and attach it to the given web component instance