-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: clone iframe nodes better #352
Conversation
Codecov ReportBase: 63.36% // Head: 63.24% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #352 +/- ##
==========================================
- Coverage 63.36% 63.24% -0.12%
==========================================
Files 10 10
Lines 565 555 -10
Branches 134 129 -5
==========================================
- Hits 358 351 -7
+ Misses 147 146 -1
+ Partials 60 58 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Can you take a look at the demo I wrote? The height of the iframe is missing, which is not as expected. thanks https://codesandbox.io/s/sweet-knuth-3n57ws?file=/index.html |
I'll take a look as I didn't have this specific issue. |
To me this doesn't seem so bad but maybe I am missing something. It did clone the iframe and the image inside, but didn't respect the height of the iframe you are saying? I'm not sure I have a solution for this atm and also I am wondering if this issue is more related to my previous merged PR where iframe cloning began. Could you clarify the expected results and suggestions if you have any? I'm not sure if this PR needs to solve this specific issue unless the code changes caused it. |
The solution for #351 PR is to replace the |
Ok thanks for clarification. It would be good if the iframe could be cloned without it being a div, unless that is the ideal solution. I'll look into it more. |
I've looked into this and it turns out that although #351 had a solution, it was not because of the div but because of changing the |
## [1.11.6](v1.11.5...v1.11.6) (2023-01-30) ### Bug Fixes * clone iframe nodes better ([#352](#352)) ([bc6b865](bc6b865))
🎉 This PR is included in version 1.11.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* fix: clone iframe nodes better * fix: switch cloned iframes from inline to blocks --------- Co-authored-by: 崖 <bubkoo.wy@gmail.com>
## [1.11.6](bubkoo/html-to-image@v1.11.5...v1.11.6) (2023-01-30) ### Bug Fixes * clone iframe nodes better ([bubkoo#352](bubkoo#352)) ([bc6b865](bubkoo@bc6b865))
* fix: clone iframe nodes better * fix: switch cloned iframes from inline to blocks --------- Co-authored-by: 崖 <bubkoo.wy@gmail.com>
## [1.11.6](bubkoo/html-to-image@v1.11.5...v1.11.6) (2023-01-30) ### Bug Fixes * clone iframe nodes better ([bubkoo#352](bubkoo#352)) ([bc6b865](bubkoo@bc6b865))
* fix: clone iframe nodes better * fix: switch cloned iframes from inline to blocks --------- Co-authored-by: 崖 <bubkoo.wy@gmail.com>
## [1.11.6](bubkoo/html-to-image@v1.11.5...v1.11.6) (2023-01-30) ### Bug Fixes * clone iframe nodes better ([bubkoo#352](bubkoo#352)) ([bc6b865](bubkoo@bc6b865))
* fix: clone iframe nodes better * fix: switch cloned iframes from inline to blocks --------- Co-authored-by: 崖 <bubkoo.wy@gmail.com>
## [1.11.6](bubkoo/html-to-image@v1.11.5...v1.11.6) (2023-01-30) ### Bug Fixes * clone iframe nodes better ([bubkoo#352](bubkoo#352)) ([bc6b865](bubkoo@bc6b865))
* fix: clone iframe nodes better * fix: switch cloned iframes from inline to blocks --------- Co-authored-by: 崖 <bubkoo.wy@gmail.com>
## [1.11.6](bubkoo/html-to-image@v1.11.5...v1.11.6) (2023-01-30) ### Bug Fixes * clone iframe nodes better ([bubkoo#352](bubkoo#352)) ([bc6b865](bubkoo@bc6b865))
My previous PR adding iframe cloning was incomplete.
Description
There were 2 specific reasons it didn't work:
instanceof
across realms (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)iframe
need to come fromcontentDocument.body.childNodes
To solve
instanceof
I've changed to comparing such as:Object.getPrototypeOf(node).constructor.name === instance.name
whereinstance
would be a prototype such asHTMLImageElement
. This will also check recursively to see for example if something likeHTMLDivElement
also hasElement
in it's prototype chain and is therefore an instance of it.Another solution suggested in MDN could be something like
myNode instanceof myNode.ownerDocument.defaultView.SVGElement
, but I had no luck (Illegal invocation
) implementing this and I feel the method I have is a bit more ideal than just checkingtagName
's.Motivation and Context
I want to fix this as I added iframe capture changes recently which caused this new issue to be visible.
Types of changes
Self Check before Merge