html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

IE - Object doesn't support property or method 'reduce'

Open dellow88 opened this issue 5 years ago • 3 comments

Hi, since the dist folder was removed then rawgit updated I have noticed some issues within IE. Initially I was using https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js however following issue @#463 I updated location to https://rawgit.com/eKoopmans/html2pdf.js/master/dist/html2pdf.bundle.min.js and now whenever I try to use html (promise based) an alert is thrown on screen and error in console... JS used: html2pdf().set(opt).from(element).outputPdf().then(function(pdf) {...).save().then( function () {...});

Error thrown Error in function s (https://rawgit.com/eKoopmans/html2pdf.js/master/dist/html2pdf.bundle.min.js:2:683077): Object doesn't support property or method 'reduce' TypeError: Object doesn't support property or method 'reduce'

Any ideas?

dellow88 avatar Sep 15 '21 00:09 dellow88

https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js differs in nothing compared to https://rawgit.com/eKoopmans/html2pdf.js/master/dist/html2pdf.bundle.min.js

There are literally no single bit of difference between the 2 files, so it is not due to the files.

What you are experiencing can be due to HTML element IDs having the same value as JS Variable names.

smileBeda avatar Sep 15 '21 10:09 smileBeda

When I used https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js I actually got an error message saying html2pdf is not defined (when using IE )and added a console.log to determine if promise was enabled and it wasn't. Im not saying original src doesnt include es6-promise but it didnt work so as a test I added es6-promise.auto.min.js to head before htm2pdf and that error went away but still got the "reduce" error message.

I haven't updated the web form where this error occurs in months so is there a change to the underlying source has changed which would affect it? I will look into html ID's clashing with JS ID's but seems very unlikely as div's/ fields are auto generated with fairly unique IDs

Thanks

dellow88 avatar Sep 17 '21 02:09 dellow88

Hi, I'm sorry for any breakages that have occurred. With v0.10 I had to switch to a different bundler (from Rollup to Webpack), that change is the likely cause of your problems.

For the time being I recommend updating your code to point to v0.9.3 - I've put instructions at the top of the readme.

eKoopmans avatar Sep 17 '21 02:09 eKoopmans