Remove marked from window (#1195)

This commit is contained in:
Paulus Schoutsen 2018-05-19 16:12:03 -04:00 committed by GitHub
parent 1eda9155fd
commit 1d144a101c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -26,7 +26,11 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
loaded = import(/* webpackChunkName: "load_markdown" */ '../resources/load_markdown.js'); loaded = import(/* webpackChunkName: "load_markdown" */ '../resources/load_markdown.js');
} }
loaded.then( loaded.then(
() => { this._scriptLoaded = 1; }, ({ marked, filterXSS }) => {
this.marked = marked;
this.filterXSS = filterXSS;
this._scriptLoaded = 1;
},
() => { this._scriptLoaded = 2; }, () => { this._scriptLoaded = 2; },
).then(() => this._render()); ).then(() => this._render());
} }
@ -41,7 +45,7 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
this._renderScheduled = false; this._renderScheduled = false;
if (this._scriptLoaded === 1) { if (this._scriptLoaded === 1) {
this.innerHTML = window.filterXSS(window.marked(this.content, { this.innerHTML = this.filterXSS(this.marked(this.content, {
gfm: true, gfm: true,
tables: true, tables: true,
breaks: true breaks: true

View File

@ -1,5 +1,5 @@
import marked from 'marked'; import marked_ from 'marked';
import filterXSS from 'xss'; import filterXSS_ from 'xss';
window.marked = marked; export const marked = marked_;
window.filterXSS = filterXSS; export const filterXSS = filterXSS_;