mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Use correct JS context to find cloned element in Edge
This commit is contained in:
parent
110c9b0eec
commit
14b4dca77c
13
src/Clone.js
13
src/Clone.js
@ -111,30 +111,31 @@ export const cloneWindow = (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const documentClone = cloneIframeContainer.contentWindow.document;
|
let cloneWindow = cloneIframeContainer.contentWindow;
|
||||||
|
const documentClone = cloneWindow.document;
|
||||||
|
|
||||||
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
|
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
|
||||||
if window url is about:blank, we can assign the url to current by writing onto the document
|
if window url is about:blank, we can assign the url to current by writing onto the document
|
||||||
*/
|
*/
|
||||||
cloneIframeContainer.contentWindow.onload = cloneIframeContainer.onload = () => {
|
cloneWindow.onload = cloneIframeContainer.onload = () => {
|
||||||
console.log('iframe load');
|
console.log('iframe load');
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (documentClone.body.childNodes.length > 0) {
|
if (documentClone.body.childNodes.length > 0) {
|
||||||
scrolledElements.forEach(initNode);
|
scrolledElements.forEach(initNode);
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
if (options.type === 'view') {
|
if (options.type === 'view') {
|
||||||
cloneIframeContainer.contentWindow.scrollTo(bounds.left, bounds.top);
|
cloneWindow.scrollTo(bounds.left, bounds.top);
|
||||||
if (
|
if (
|
||||||
/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
|
/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
|
||||||
(cloneIframeContainer.contentWindow.scrollY !== bounds.top ||
|
(cloneWindow.scrollY !== bounds.top ||
|
||||||
cloneIframeContainer.contentWindow.scrollX !== bounds.left)
|
cloneWindow.scrollX !== bounds.left)
|
||||||
) {
|
) {
|
||||||
documentClone.documentElement.style.top = -bounds.top + 'px';
|
documentClone.documentElement.style.top = -bounds.top + 'px';
|
||||||
documentClone.documentElement.style.left = -bounds.left + 'px';
|
documentClone.documentElement.style.left = -bounds.left + 'px';
|
||||||
documentClone.documentElement.style.position = 'absolute';
|
documentClone.documentElement.style.position = 'absolute';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (referenceElementSearch[1] instanceof HTMLElement) {
|
if (referenceElementSearch[1] instanceof cloneWindow.HTMLElement || referenceElementSearch[1] instanceof HTMLElement) {
|
||||||
resolve([cloneIframeContainer, referenceElementSearch[1]]);
|
resolve([cloneIframeContainer, referenceElementSearch[1]]);
|
||||||
} else {
|
} else {
|
||||||
reject(
|
reject(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user