<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Javascript on Duma's website</title><link>https://dumaron.github.io/tags/javascript/</link><description>Recent content in Javascript on Duma's website</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 30 Jan 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://dumaron.github.io/tags/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title>Web Components innerHTML and loading time</title><link>https://dumaron.github.io/notes/tils/2024-01-30_webc_innerhtml_and_loading_time/</link><pubDate>Tue, 30 Jan 2024 00:00:00 +0000</pubDate><guid>https://dumaron.github.io/notes/tils/2024-01-30_webc_innerhtml_and_loading_time/</guid><description>&lt;p&gt;While approaching the first lessons of &#10;&#10;&lt;a href="https://www.bluespire.com/p/web-component-engineering" rel="noopener" target="_blank"&gt;Rob Eisenberg&amp;rsquo;s Web Components course&lt;/a&gt;, I stumpled upon a browser error that prevented every instance&#10;of a web component to run:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Failed to construct &amp;#39;CustomElement&amp;#39;: The result must not have children&amp;#34;&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After many trials and errors, it turned out that adding the &lt;code&gt;type=&amp;quot;module&amp;quot;&lt;/code&gt; attribute fixed the issue. But why?&#10;I asked Rob directly &#10;&#10;&lt;a href="https://twitter.com/Duma_ron/status/1752283582368731598" rel="noopener" target="_blank"&gt;in this tweet&lt;/a&gt;, and here&amp;rsquo;s his answer:&lt;/p&gt;&#10;&lt;blockquote&gt;&lt;p&gt;Technically, one shouldn&amp;rsquo;t alter the host attributes or children in the constructor (there&amp;rsquo;s a note on attributes but not children in the lesson; I&amp;rsquo;ll add more on that). Though, it will work in certain scenarios. Setting innerHTML in the constructor is an example of where it will work, depending on the timing.&lt;/p&gt;</description></item></channel></rss>