Skip to content

Commit

Permalink
Prevent snapshots from loading media and upgrading custom elements un…
Browse files Browse the repository at this point in the history
…necessarily
  • Loading branch information
javan committed Sep 12, 2019
1 parent 16f80a1 commit 5dfc79e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ export class Snapshot {
}

static fromHTMLString(html: string) {
const element = document.createElement("html")
element.innerHTML = html
return this.fromHTMLElement(element)
const { documentElement } = new DOMParser().parseFromString(html, "text/html")
return this.fromHTMLElement(documentElement as HTMLHtmlElement)
}

static fromHTMLElement(htmlElement: HTMLHtmlElement) {
Expand All @@ -35,7 +34,8 @@ export class Snapshot {
}

clone(): Snapshot {
return new Snapshot(this.headDetails, this.bodyElement.cloneNode(true))
const { bodyElement } = Snapshot.fromHTMLString(this.bodyElement.outerHTML)
return new Snapshot(this.headDetails, bodyElement)
}

getRootLocation() {
Expand Down

0 comments on commit 5dfc79e

Please sign in to comment.