You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The transform for import.meta.document in html-module-transform.ts generates a selector for the script element that the expression appears in, like: 'script[data-inline-module-script="0"]'
According to the explanation in the MS explainer, import.meta.document is supposed to refer to the HTML Module document, not a the inner <script> element.
I think the fix would be as simple as adding parentElement at the end.
Here's an example source illustrating the issue:
<template id="header">
<div>HTML Modules</div>
</template>
<script type="module">
let importDoc = import.meta.document;
// Shouldn't need this line since `import.meta.document` is supposed to refer to this whole
// HTML document. The
importDoc = importDoc.parentElement;
class Component extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
const template = importDoc.querySelector('#header');
shadowRoot.appendChild(template.content.cloneNode(true));
}
}
customElements.define('my-component', Component);
</script>
The text was updated successfully, but these errors were encountered:
As you can probably tell, this project predated the latest proposals for HTML Modules, and hasn't received a lot of attention since Microsoft starting pushing for them.
PRs are welcome if you or anyone else wants to help us bring these transforms up to date with the latest proposals! 🙏
The transform for
import.meta.document
in html-module-transform.ts generates a selector for the script element that the expression appears in, like:'script[data-inline-module-script="0"]'
According to the explanation in the MS explainer,
import.meta.document
is supposed to refer to the HTML Module document, not a the inner <script> element.I think the fix would be as simple as adding
parentElement
at the end.Here's an example source illustrating the issue:
The text was updated successfully, but these errors were encountered: