File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -266,12 +266,19 @@ export function parseJsx(moduleURL) {
266
266
applyDomDepthSubstitutions ( elementTree , undefined , hasShadowRoot ) ;
267
267
268
268
const serializedHtml = serialize ( elementTree ) ;
269
- // would be nice to reuse HTMLTemplateElement here...
270
- const finalHtml = hasShadowRoot
271
- ? `<template shadowrootmode="open">${ serializedHtml } </template>`
272
- : serializedHtml ;
273
-
274
- const transformed = acorn . parse ( `${ elementRoot } .innerHTML = \`${ finalHtml } \`;` , {
269
+ // could / should we do something else instead of .innerHTML for light DOM?
270
+ // https://github.com/ProjectEvergreen/wcc/issues/130
271
+ const renderHandler = hasShadowRoot
272
+ ? `
273
+ if(!${ elementRoot } .shadowRoot) {
274
+ const template = document.createElement('template');
275
+
276
+ template.innerHTML = \`${ serializedHtml } \`;
277
+ this.shadowRoot.appendChild(template.content.cloneNode(true));
278
+ }
279
+ `
280
+ : `${ elementRoot } .innerHTML = \`${ serializedHtml } \`;` ;
281
+ const transformed = acorn . parse ( renderHandler , {
275
282
ecmaVersion : 'latest' ,
276
283
sourceType : 'module'
277
284
} ) ;
You can’t perform that action at this time.
0 commit comments