html2canvas
html2canvas copied to clipboard
ERROR Error: Uncaught (in promise): Unable to find element in cloned iframe
Bug reports:
I found a problem when using Angular.
Does the transformed element have to be visible?
an example on stackblitz.
Specifications:
- html2canvas version tested with: v1.4.1
- Browser & version: Chrome v103.0.5060.134
- Operating system: windows 11
+1
Also having this issue with generated svg components in react
How to solve this problem?
I had the same issue, not using angular.
In my case the problem was that for some reason, html2canvas didn't like when you do appendChild to body element, but it worked when you prepend rendered element to body. For some reason place of rendered element matters somehow, so if anyone looking for a solution - just try to prepend / append rendered element to a different place.
In case with react / angular / vue it means that you should get rendered element from component, copy it and appened it somewhere else. Hope it helps.
I've reproduced the issue in react with svg build with visx: https://codesandbox.io/s/visx-html2canvas-issue-l7ox9x?file=/src/App.js
Does anyone have an idea, how to fix it?
I've reproduced the issue in react with svg build with visx: https://codesandbox.io/s/visx-html2canvas-issue-l7ox9x?file=/src/App.js
Does anyone have an idea, how to fix it?
+1
Has resolved; Error reason: the issue of DOM rendering timing, the DOM actually fetched by the first parameter of HTML2canvas is the Canvas cache; Solution: A variable is named on the outermost part of the component, and the DOM is reassigned each time inside the component, preventing the cache from being obtained
Has resolved; Error reason: the issue of DOM rendering timing, the DOM actually fetched by the first parameter of HTML2canvas is the Canvas cache; Solution: A variable is named on the outermost part of the component, and the DOM is reassigned each time inside the component, preventing the cache from being obtained
can you share your implementation
+1
I found the problem. html2canvas traverses document nodes, but the element nodes projected in angular are not in document
Not only Angular, but many other non-HTML tags report the same error
------------------ 原始邮件 ------------------ 发件人: "niklasvh/html2canvas" @.>; 发送时间: 2023年8月14日(星期一) 上午9:24 @.>; @.@.>; 主题: Re: [niklasvh/html2canvas] ERROR Error: Uncaught (in promise): Unable to find element in cloned iframe (Issue #2929)
I found the problem. html2canvas traverses document nodes, but the element nodes projected in angular are not in document
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
Also having this issue with generated svg components in react
Same. Issue with generated svgs.
@kenjicncr or anyone, how did you resolve this issue ?
I get the same issue here , in case the element is in ShadowDOM
how to solve it
在反应中生成的 svg 组件也有这个问题
相同的。生成的 svgs 存在问题。
@kenjicncr或者任何人,你是如何解决这个问题的?
how to fix it?