Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Use docElement.outerHTML, not DOMParser, to insert html page into iframe
Browse files Browse the repository at this point in the history
Addresses comments 2 and 3 inside selector/ui.js
  • Loading branch information
jaredhirsch authored and ianb committed Apr 7, 2017
1 parent a58ea0e commit fb81559
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions addon/webextension/selector/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,15 @@ var ui = (function () { // eslint-disable-line no-unused-vars
this.element.scrolling = "no";
this.updateElementSize();
this.element.onload = watchFunction(() => {
let parsedDom = (new DOMParser()).parseFromString(`
this.document = this.element.contentDocument;
this.document.documentElement.outerHTML = `
<html>
<head>
<style>${substitutedCss}</style>
<title></title>
</head>
<body></body>
</html>`,
"text/html"
);
this.document = this.element.contentDocument;
this.document.replaceChild(
this.document.adoptNode(parsedDom.documentElement),
this.document.documentElement
);
</html>`;
installHandlerOnDocument(this.document);
if (this.addClassName) {
this.document.body.className = this.addClassName;
Expand Down Expand Up @@ -225,7 +219,8 @@ var ui = (function () { // eslint-disable-line no-unused-vars
this.element.scrolling = "no";
this.updateElementSize();
this.element.onload = watchFunction(() => {
let parsedDom = (new DOMParser()).parseFromString(`
this.document = this.element.contentDocument;
this.document.documentElement.outerHTML = `
<html>
<head>
<style>${substitutedCss}</style>
Expand All @@ -244,14 +239,7 @@ var ui = (function () { // eslint-disable-line no-unused-vars
</div>
</div>
</body>
</html>`,
"text/html"
);
this.document = this.element.contentDocument;
this.document.replaceChild(
this.document.adoptNode(parsedDom.documentElement),
this.document.documentElement
);
</html>`;
installHandlerOnDocument(this.document);
if (this.addClassName) {
this.document.body.className = this.addClassName;
Expand Down

0 comments on commit fb81559

Please # to comment.