Skip to content
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

window.html2canvas is undefined if a module loader is used #834

Closed
rrutkows opened this issue Mar 24, 2016 · 4 comments
Closed

window.html2canvas is undefined if a module loader is used #834

rrutkows opened this issue Mar 24, 2016 · 4 comments

Comments

@rrutkows
Copy link

Because html2canvas and html2canvas.svg are bundled as UMD, window.html2canvas will be undefined in applications that use a module loader.

@rrutkows
Copy link
Author

As a result you get a

"Unable to get property 'svg' of undefined or null reference"

error in IE, whenever it tries to use fabric.

An AMD workaround:

require(["html2canvas", "html2canvas.svg"], function(html2canvas, svg) {
  window.html2canvas = {
    svg: svg
  };

@nearwood
Copy link

nearwood commented Feb 6, 2017

And if you're using babel/es6:

  import html2canvas from 'html2canvas';
  window.html2canvas = {
    svg: html2canvas.svg
  };

@doubleppereira
Copy link

doubleppereira commented Mar 3, 2017

Tried to do this and I am getting an blank image..any idea of what could be causing this?
I am using version 0.5.0-beta4. and doing:

html2canvas(captureTarget, {
           allowTaint: true
       }).then(canvas => {
           let imagex64 = canvas.toDataURL(); });

when I display that image is blank.

@RichardBradley
Copy link

RichardBradley commented May 15, 2018

I had the same issue in MSIE 11.1, but it does not happen in Chrome.

A variant on nearwood's workaround stops the error, but SVGs do not render properly:

import * as html2canvas from 'html2canvas';
(window as any).html2canvas = {
    svg: html2canvas.svg
};

@niklasvh, why did you close this? Is it thought fixed? I don't see any commits which reference this issue: do you have a link to what fixed this in Chrome, so I can take a look at why it is still broken in MSIE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants