Import an external HTML snippets.
<p>I am html</p>
<k-import src="import-me.html"></k-import>
<k-import src="import-me.html" rendered="true">
<p>I am html</p>
</k-import>
new Import()
src: stringThe source URL of the HTML snippet to import. Syncs to src attribute.
fetch(): PromiseFetches and renders the HTML snippet from the current src URL. Called automatically when src changes.
src-changeFired when the src property changes. detail: { src }
fetch-startFired when the HTTP fetch begins. detail: { src }
fetch-responseFired when the HTTP response is received. detail: { src, status }
content-renderedFired after the HTML content has been injected into the DOM and all inline scripts have been executed.
const importer = document.querySelector('k-import');
importer.addEventListener('src-change', e => console.log('src set:', e.detail.src));
importer.addEventListener('fetch-start', e => console.log('fetching:', e.detail.src));
importer.addEventListener('fetch-response', e => console.log('response status:', e.detail.status));
importer.addEventListener('content-rendered', () => console.log('content ready'));