Created
April 16, 2019 22:38
-
-
Save ivanhoe011/7e4ec2bb78367c2ceb3aabcd337c95ba to your computer and use it in GitHub Desktop.
Custom HTML element simulating iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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