Open joshualoehr opened 9 months ago
👋 @joshualoehr
💖 Thanks for opening this pull request! 💖
Please follow the contributing guidelines. And we use semantic commit messages to streamline the release process.
Examples of commit messages with semantic prefixes:
fix: don't overwrite prevent_default if default wasn't prevented
feat: add graph.scale() method
docs: graph.getShortestPath is now available
Things that will help get your PR across the finish line:
npm run lint
locally to catch formatting errors earlier.We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.
Patch and project coverage have no change.
Comparison is base (
b751cbf
) 62.93% compared to head (eba8d40
) 62.93%. Report is 3 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
Currently, iframe content is duplicated during the recursive
cloneNode
process. See this repo for a minimal reproduction of the issue: https://github.com/joshualoehr/html-to-image-iframe-bugI'm new to this library so it's not clear to me if there's a downside to the fix I'm proposing, or a better way to approach a solution. But all of the existing tests pass and the new test I've added covers the scenario in my repro repo.
Motivation and Context
When the iframe node is originally passed into
cloneNode
, it is forwarded tocloneSingleNode
. IncloneSingleNode
, the iframe's document body is extracted and recursively passed back intocloneNode
as another root node. That lattercloneNode
call takes care of cloning all of the iframe content just fine.However, since the original call to
cloneNode
with the iframe node is still promise-chained, it will then pass throughcloneChildren
,decorate
, andensureSVGSymbols
again, after its document body node has already done so. That causes the iframe's body and other nested contents to be cloned again, redundantly. The result is two copies of the iframe contents in the SVG.The changes in this PR stop
cloneChildren
anddecorate
from doing anything if operating on the iframe node itself, rather than its nested document body.ensureSVGSymbols
seems to be irrelevant for iframes, so I've left it alone.Types of changes
Self Check before Merge