Giter Club home page Giter Club logo

Comments (17)

AnnoyingTechnology avatar AnnoyingTechnology commented on July 21, 2024 1

Were you able to solve this issue @AnnoyingTechnology ?

Hi, sadly no. I had to use a workaround without using an iframe.

The workaround being : using Google Street View static image API.

from dom-to-image-more.

ransomsumit avatar ransomsumit commented on July 21, 2024 1

@IDisposable Here is the fix
https://github.com/ransomsumit/dom-to-image/blob/master/src/dom-to-image.js

from dom-to-image-more.

southpush avatar southpush commented on July 21, 2024

Try to use toPng, I get a black picture too when I use toJpeg, but work well in toPng

from dom-to-image-more.

AnnoyingTechnology avatar AnnoyingTechnology commented on July 21, 2024

Thanks for the tip. But this had already been tried without success.

from dom-to-image-more.

ransomsumit avatar ransomsumit commented on July 21, 2024

Were you able to solve this issue @AnnoyingTechnology ?

from dom-to-image-more.

IDisposable avatar IDisposable commented on July 21, 2024

Does adding allow="accelerometer; magnetometer; gyroscope" to the iframe work? That would allow the device sensors inside third-party domain loaded scripts.

from dom-to-image-more.

ransomsumit avatar ransomsumit commented on July 21, 2024

Hey Guys, i just found a big bug with the instanceof checks in the source code.
Trying instanceof with a dom element situated inside an iframe on window prototypes gives false on chrome but gives true on firefox.

Fixing this solved my issue with iframes.

from dom-to-image-more.

IDisposable avatar IDisposable commented on July 21, 2024

@ransomsumit Did you have a PR or a general fix or more details you would like to contribute?

from dom-to-image-more.

IDisposable avatar IDisposable commented on July 21, 2024

Thanks! I've generalized it a bit more to reach up into the contentWindow as needed. Can you confirm that the version in PR #80 works for you so I can make a general release?

from dom-to-image-more.

ransomsumit avatar ransomsumit commented on July 21, 2024

No it doesn't work properly. it's missing out on styles for several tags. @IDisposable

from dom-to-image-more.

IDisposable avatar IDisposable commented on July 21, 2024

Any suggestion as to what we're missing? I would love to roll out a fix.

from dom-to-image-more.

ransomsumit avatar ransomsumit commented on July 21, 2024

The one thing I noticed is that some tags For ex. < g > gives out false on instanceof check within the frame for some reason but gives true on root window. So the fail safe will be to check instanceof on root window and the frame window at the same time with proper condition. My fix is working fine with this.

Currently,
I am tackling some weird image event error with makeimage function, if you have any context please tell. @IDisposable

from dom-to-image-more.

IDisposable avatar IDisposable commented on July 21, 2024

I've pushed up some more extensive cleanup, mostly around the finding of the owner window object and also fixed a really silly issue with class name generation used when copying over any ::before or ::after attributes.

Please pull the branch again and see if I've got it working. If you can give me a repro that show the error, I can fix it faster (follow the pattern in the unit testes... an HTML, a CSS, (optionally) a control-image.

from dom-to-image-more.

zoltanseer avatar zoltanseer commented on July 21, 2024

Maybe it's because iframe has loading=lazy attribute

from dom-to-image-more.

zm-cttae avatar zm-cttae commented on July 21, 2024

Parallel to the iframe feature request:

getComputedStyle recomputes layout. We want to target recomputes to the element's window, not `global || window`.

I believe the internal implementation in Blink:

  • reaches up from element.ownerDocument.defaultView back to global || window making this change a 5-10% slight slowdown 
  • also that window.getComputedStyle triggers a layout recompute in iframes anyway

It just seems more robust to be using the window that's the immediate context of the element itself. We could do this in #108 or when we implement iframes.. if the latter, let's add it to this PR.

from dom-to-image-more.

zm-cttae avatar zm-cttae commented on July 21, 2024

For iframe cloning:

  • We should first check if there is an srcdoc because that is usually inlined as a higher priority than the <iframe> src.
  • Same origin = iframe.contentDocument is available: we can attempt a jump from iframe to iframe.contentDocument when getting the children. Similar to #101.
  • Otherwise there should be the option to fetch the HTML of src via XHR and inline it.

from dom-to-image-more.

zm-cttae avatar zm-cttae commented on July 21, 2024

Resources inside the cloned iframe document don't load after the XHR. So cross-origin support is a no-no.
I believe Google Street View is always a cross-origin embed/iframe so it's impossible to take a screenshot of without retooling some kind of advanced browser API and requiring user input after the toSvg call.

from dom-to-image-more.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.