UNPKG

862 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5const __chunk_1 = require('./stencilrouter-a3d77a87.js');
6
7class AsyncContent {
8 constructor(hostRef) {
9 __chunk_1.registerInstance(this, hostRef);
10 this.content = '';
11 }
12 componentWillLoad() {
13 if (this.documentLocation != null) {
14 return this.fetchNewContent(this.documentLocation);
15 }
16 }
17 fetchNewContent(newDocumentLocation) {
18 return fetch(newDocumentLocation)
19 .then(response => response.text())
20 .then(data => {
21 this.content = data;
22 });
23 }
24 render() {
25 return (__chunk_1.h("div", { innerHTML: this.content }));
26 }
27 static get watchers() { return {
28 "documentLocation": ["fetchNewContent"]
29 }; }
30}
31
32exports.stencil_async_content = AsyncContent;