Skip to content

Commit

Permalink
FirenvimElement.ts: don't insert frame in body if it is frame target
Browse files Browse the repository at this point in the history
  • Loading branch information
glacambre committed Jan 9, 2021
1 parent d3a2a3b commit a498f97
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/FirenvimElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,14 @@ export class FirenvimElement {
})(this));
this.spanObserver.observe(this.getElement().ownerDocument.body, { childList: true });

this.getElement().ownerDocument.body.appendChild(this.span);
let parentElement = this.getElement().ownerDocument.body;
// We can't insert the frame in the body if the element we're going to
// replace the content of is the body, as replacing the content would
// destroy the frame.
if (parentElement === this.getElement()) {
parentElement = parentElement.parentElement;
}
parentElement.appendChild(this.span);

this.focus();

Expand Down

0 comments on commit a498f97

Please sign in to comment.