From 8b653f89bca2870e099da584f19f06b7ab76fc53 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 7 Dec 2017 16:16:22 +0800 Subject: [PATCH] Prevent generated iframe from getting re-rendered --- src/Clone.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Clone.js b/src/Clone.js index c60cc14..f156bdd 100644 --- a/src/Clone.js +++ b/src/Clone.js @@ -11,6 +11,8 @@ import {copyCSSStyles} from './Util'; import {parseBackgroundImage} from './parsing/background'; import CanvasRenderer from './renderer/CanvasRenderer'; +const IGNORE_ATTRIBUTE = 'data-html2canvas-ignore'; + export class DocumentCloner { scrolledElements: Array<[HTMLElement, number, number]>; referenceElement: HTMLElement; @@ -235,7 +237,8 @@ export class DocumentCloner { for (let child = node.firstChild; child; child = child.nextSibling) { if ( child.nodeType !== Node.ELEMENT_NODE || - (child.nodeName !== 'SCRIPT' && !child.hasAttribute('data-html2canvas-ignore')) + // $FlowFixMe + (child.nodeName !== 'SCRIPT' && !child.hasAttribute(IGNORE_ATTRIBUTE)) ) { if (!this.copyStyles || child.nodeName !== 'STYLE') { clone.appendChild(this.cloneNode(child)); @@ -496,6 +499,7 @@ const createIframeContainer = ( cloneIframeContainer.width = bounds.width.toString(); cloneIframeContainer.height = bounds.height.toString(); cloneIframeContainer.scrolling = 'no'; // ios won't scroll without it + cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, 'true'); if (!ownerDocument.body) { return Promise.reject( __DEV__ ? `Body element not found in Document that is getting rendered` : ''