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
<td><ahref="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/DOM-Parts.md">DOM Part API - First Step of Template Instantiation</a></td>
<p>HTML Modules would provide a means of referencing HTML through the web's module system. For Web Components specifically, this would allow the usage of <code>import</code> to load and initialize the template of a custom element, much in the same way <ahref="#css-module-scripts">CSS Modules</a> would work for an <code>adoptedStyleSheet</code>.</p>
1754
+
<p>Additionally, this could open up the concept of <ahref="https://github.com/WICG/webcomponents/issues/645#issuecomment-343601237">Single File Components (SFC)</a> to the web.</p>
1773
1755
</section>
1774
1756
<section>
1775
1757
<h3>Status</h3>
1776
1758
<ul>
1777
-
<li>---</li>
1759
+
<li>Chrome (shipped, but not aligned with ESM)</li>
1778
1760
</ul>
1779
1761
</section>
1780
1762
<section>
1781
1763
<h3>Initial API Summary/Quick API Proposal</h3>
1782
-
<p>Summary or proposal based on current status; paragraph(s) and code.</p>
1764
+
<preclass="javascript">
1765
+
import template from 'my-template.html' as HTMLTemplateElement;
1766
+
1767
+
MyCustomElement extends HTMLElement {
1768
+
constructor() {
1769
+
const root = this.attachShadow({mode: 'closed'});
1770
+
root.appendChild(document.importNode(template));
1771
+
}
1772
+
}
1773
+
</pre>
1783
1774
</section>
1784
1775
<section>
1785
1776
<h3>Key Scenarios</h3>
1786
-
<p>---</p>
1777
+
<p>The primary motivation for HTML Modules is to round out ESM so that all of the three main web languages (HTML / CSS / JS) can be leveraged through a module system. For Web Components, this is especially helpful for scenarios related to Server Side Rendering or any form of templating, static or otherwise. Having a common mechanism in JavaScript to author and use Web Components makes for a great experience all around.</p>
1778
+
<p>Additionally it will work great if you prefer to separate your technologies (e.g. <em>my-component.(js|css|html)</em> ), or your (CSS|HTML)-in-JS</p> in one file.
1787
1779
</section>
1788
1780
<section>
1789
1781
<h3>Concerns</h3>
1790
1782
<ul>
1791
-
<li>---</li>
1783
+
<li>Main concern is that now that ESM and Import Assertions are a thing, it is recognized that the proposal for HTML Modules needs to be re-drafted accordingly.</li>
0 commit comments