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

IE 11 issue, Error: Uncaught (in promise): Error: Member not found. #1374

Closed
Prabhat2404 opened this issue Jan 8, 2018 · 36 comments
Closed

Comments

@Prabhat2404
Copy link

Prabhat2404 commented Jan 8, 2018

Got error : "html2canvas $npm_package_version. Error: Uncaught (in promise): Error: Member not found."
When i try to get canvas.

Code:
html2canvas(document.querySelector("#capture")).then(function (canvas) {
console.log(canvas);
document.getElementById('here-appear-theimages').appendChild(canvas);
});
Using:
Angular version : 4.0.1
OS: Window 10
Also added refrence of: https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.js
Attached error screenshot.

error_ie_11

@jelkins8
Copy link

jelkins8 commented Jan 8, 2018

I added a link to the following promise library and it seemed to fix IE 11 for us.
https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js

@niklasvh
Copy link
Owner

niklasvh commented Jan 9, 2018

Without code to reproduce the error I can't really help.

@Prabhat2404
Copy link
Author

Prabhat2404 commented Jan 9, 2018

Hi @niklasvh ,

This is demo sample i have hosted on GitHub you can see - GitHub Html2Canvas Demo

Full code is also uploaded on github, if you want to see: Code package

How to run project:

  1. Unzip package
  2. Run command: "npm install" from directory to install dependency
  3. To run project command: "npm start"

@Prabhat2404
Copy link
Author

Hi @jelkins8,

I have tried this solution but its not working for me.
This is demo sample i have hosted on GitHub you can see - GitHub Html2Canvas Demo

Thanks

@simonpinn
Copy link
Contributor

simonpinn commented Jan 23, 2018

Hi @niklasvh ,
I too have tried with es6-promise and bluebird without success in IE11, can confirm that GitHub Html2Canvas Demo also fails in IE for me.
I receive html2canvas: Error: Member not found. followed by Possible Unhandled Promise Rejection: Error: Member not found.
thanks!

updated, after using the bluebird polyfill my stack trace is:

Error: Member not found.
at Anonymous function (eval code:213:21)
   at createElementClone (eval code:212:17)
at cloneNode (eval code:225:13)
at cloneNode (eval code:248:25)
at cloneNode (eval code:248:25)
 at DocumentCloner (eval code:53:9)
at cloneWindow (eval code:505:5)
at Anonymous function (eval code:53:9)
at r (https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js:31:6804)
at r.prototype._settlePromiseFromHandler (https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js:30:12222)

@GPranali
Copy link

I am facing the same issue for html2canvas: member not found for IE.
For chrome it is working perfectly fine.
Please update if any solution. Thanks

@simonpinn
Copy link
Contributor

I've reproduced the issue and located the cause, it happens in the createElementClone function when it attempts to access the cssText property, for some reason when using font-awesome, an element with fa-spin throws this error in IE when accessing the property.

As follows works:

if (node instanceof HTMLStyleElement && node.sheet && node.sheet.cssRules) {
              var style = node.cloneNode(false);
                  var css = [].slice.call(node.sheet.cssRules, 0).reduce(function (css, rule) {
                    try {
                      if (rule && rule.cssText) {
                        return css + rule.cssText;
                      }
                      return css;
                    } catch (err) {
                      _this3.logger.log('Unable to access cssText property', rule.name);
                    }
                  }, '');
                  style.textContent = css;

                return style;
            }

Note the try...catch.

I'll raise a PR.

@simonpinn
Copy link
Contributor

Appears to cause a regression in Firefox 58.0.0 (Linux 0.0.0) /tests/reftests/background/radial-gradient2.html Should render untainted canvas FAILED @niklasvh any chance you could take a look?

thanks

@Prabhat2404
Copy link
Author

Hi @niklasvh,
Have you got any solution for this, is any one looking on this issue ?

Thanks

@simonpinn
Copy link
Contributor

Hi @Prabhat2404, the fix I've proposed in #1415 works great for me, however it does fail one of the radial gradient tests, which I've asked @niklasvh to have a look at. The issue occurs for me when using font-awesome icons, in particular fa-spin.

@stephanepericat
Copy link

same problem here

@oleksandrstarov
Copy link

The issue is still exists for IE in case we try to print html code.
Is there any workaround to not modify library source code and solve the issue?

@evgenyjam
Copy link

+1

2 similar comments
@BrunoMarc
Copy link

+1

@mr0n3
Copy link

mr0n3 commented Mar 28, 2018

+1

@evgenyjam
Copy link

It helps for me!

@cyouden
Copy link

cyouden commented Mar 28, 2018

@evgenyjam That solution still has a bug, you need to add an empty string as the initial value for reduce.

I mentioned that on the PR, but the author hasn't updated it yet. But with that change it works for me.

@BrunoMarc
Copy link

@cyouden this way?
.reduce(("", css, rule) => {

@cyouden
Copy link

cyouden commented Mar 28, 2018

@BrunoMarc No, it's the last argument for reduce, so:
.reduce((css, rule) => { /* code */ }, "")

(E.g. see the code the change is proposed to replace in that diff, it correctly uses the initial value for reduce.)

@BrunoMarc
Copy link

BrunoMarc commented Mar 28, 2018

@cyouden Thanks for the response! I have inserted this code in html2canvas.js but the Member not found still persist, any ideas?
if (node instanceof HTMLStyleElement && node.sheet && node.sheet.cssRules) {
const css = [].slice
.call(node.sheet.cssRules, 0)
.reduce((css, rule) => {
try {
if (rule && rule.cssText) {
return css + rule.cssText;
}
return css;
} catch (err) {
this.logger.log('Unable to access cssText property', rule.name);
return css;
}
}, '');
const style = node.cloneNode(false);
style.textContent = css;
return style;
}

@cyouden
Copy link

cyouden commented Mar 28, 2018

@BrunoMarc No idea, that change was enough to get it working for me.

@simonpinn
Copy link
Contributor

Hey - sorry to be late to the party, I've just committed a change with the default empty string for the reduce, as suggested, hope that helps!
cheers

@simonpinn
Copy link
Contributor

@niklasvh @BrunoMarc @cyouden good news the build is passing for the PR
Sorry I didn't update earlier, I'd actually moved on from moving the library, I'd come across the bug while using it in a spike. Hope it helps!

@bandacs
Copy link

bandacs commented Mar 28, 2018

@simonpinn I am trying to use html2canvas-1.0.0-alpha.10 version for my angular 4 code. I am getting following error in all browsers. And only part of html is getting printed.

34487ms html2canvas: html2canvas $npm_package_version
core.js:1427 ERROR Error: Uncaught (in promise): undefined
at resolvePromise (zone.js:824)
at resolvePromise (zone.js:795)
at eval (zone.js:873)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4747)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at drainMicroTaskQueue (zone.js:602)
at ZoneTask.invokeTask [as invoke] (zone.js:503)
at invokeTask (zone.js:1540)
defaultErrorLogger @ core.js:1427
ErrorHandler.handleError @ core.js:1488
Logger.js:36 83270ms html2canvas: Finished parsing node tree
Invalid value given for Length: "auto"

@bandacs
Copy link

bandacs commented Mar 28, 2018

@simonpinn I am using the way as follows. Is there any issue with latest version 1.0.0-alpha.10 in tyscript (angular 4) code? Can you please help me with solution. I am very much in need.

image

@simonpinn
Copy link
Contributor

@bandacs this issue is for solving an IE 11 error for uncaught promises, please raise an issue against the alpha.10 build, if you are having a problem.

thanks

@bandacs
Copy link

bandacs commented Mar 30, 2018

@simonpinn @cyouden
Following up the above defect. I found the other library (dom-to-image) for Chrome and and Firefox browsers. But the issue still continues in IE. When I go through the above conversation, I got to know that empty string workaround fixes the defect. Is that work around working? Also may I know when that change will be included in library?

niklasvh pushed a commit that referenced this issue Apr 1, 2018
…...catch (#1415)

* #1374 - Wrap accesing the cssText property in a try...catch
@niklasvh
Copy link
Owner

niklasvh commented Apr 2, 2018

Fix merged in v1.0.0-alpha.11

@niklasvh niklasvh closed this as completed Apr 2, 2018
@tkantharia
Copy link

tkantharia commented Apr 10, 2018

I have reactjs project and i did npm install for html2canvas updates. but in IE 11 browser its still showing me Member not found error. Please help. I checked on Windows 8 system

@sarahbenjamin
Copy link

I am using the v1.0.0-alpha.11 and it works great in Chrome but getting an error on IE 11 on the same lines
html2canvas(panel).then(canvas => {
var img = canvas.toDataURL("image/png");
});

@ulrichmueller
Copy link

Hello. Same error for me. Our customer uses IE11 as default ...

@fasidOnGit
Copy link

fasidOnGit commented May 10, 2019

Fixed it!!
Open node_modules/html2canvas/dist/html2canvas.js
Search for if (rule && rule.cssText)
and Change it to if (rule && typeof rule.cssText === 'string')
This fixed the problem for me in IE11 :)

@niklasvh
Copy link
Owner

fixed with bc270bb

@seshadriallimani
Copy link

Hi All,
I am also having the below issue which fixed:
Open node_modules/html2canvas/dist/html2canvas.js
Search for if (rule && rule.cssText)
and Change it to if (rule && typeof rule.cssText === 'string')
This fixed the problem for me in IE11 :)

How can i get a new published version of it to use in my project? currently i tested by editing in node-modules in my local environment. to push it production need a new published version of 'html2canvas' version? can you please help me to get it?

@seshadriallimani
Copy link

Currently i am using the "html2canvas": "^1.0.0-rc.1", which doesn't have the fix.

@seshadriallimani
Copy link

Hi @niklasvh, can you tell me when new version will be release with the fix for issue #1374 . Eagerly waiting to see fix in the version.

BensmanF added a commit to BensmanF/html-canvas that referenced this issue Sep 10, 2024
…...catch (#1415)

* niklasvh/html2canvas#1374 - Wrap accesing the cssText property in a try...catch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.