UNPKG

781 BJavaScriptView Raw
1import { r as registerInstance, h } from './stencilrouter-1307249c.js';
2
3class AsyncContent {
4 constructor(hostRef) {
5 registerInstance(this, hostRef);
6 this.content = '';
7 }
8 componentWillLoad() {
9 if (this.documentLocation != null) {
10 return this.fetchNewContent(this.documentLocation);
11 }
12 }
13 fetchNewContent(newDocumentLocation) {
14 return fetch(newDocumentLocation)
15 .then(response => response.text())
16 .then(data => {
17 this.content = data;
18 });
19 }
20 render() {
21 return (h("div", { innerHTML: this.content }));
22 }
23 static get watchers() { return {
24 "documentLocation": ["fetchNewContent"]
25 }; }
26}
27
28export { AsyncContent as stencil_async_content };