Skip to content

Instantly share code, notes, and snippets.

@ivanhoe011
Created April 16, 2019 22:38
Show Gist options
  • Select an option

  • Save ivanhoe011/7e4ec2bb78367c2ceb3aabcd337c95ba to your computer and use it in GitHub Desktop.

Select an option

Save ivanhoe011/7e4ec2bb78367c2ceb3aabcd337c95ba to your computer and use it in GitHub Desktop.
Custom HTML element simulating iframe
class HTMLInclude extends HTMLElement {
static observedAttributes = ['href'];
async attributeChangedCallback(name, value) {
if (name === 'href') {
this.innerHTML = await (await fetch(value)).text();
}
}
}
customElements.define('html-include', HTMLInclude);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment