html2canvas: Color-stop matching fails with TypeError due to faulty regexp

I’m seeing a TypeError when using color keywords (e.g. transparent, as opposed to rgb() values) since matching against the “step” regex in LinearGradientContainer will always return null in that case (see this line).

Can you please update the regexp to work as expected with both [a-z]+ color keywords as well as the rgb()/rgba() functional notation? Or would you be open to a pull request that does just that? (I can even add hsl()/hsla() support to the regexp, if you want…) Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 29 (25 by maintainers)

Commits related to this issue

Most upvoted comments

@usmonster @niklasvh Hello guys I know this issue is closed but I am using the latest version of html2canvas and I am getting the same error in Chrome latest version but in Firefox it is working.

html2canvas.js:formatted:1377 Uncaught (in promise) TypeError: Cannot read property ‘1’ of null at LinearGradientContainer.<anonymous> (html2canvas.js:formatted:1377) at Array.map (<anonymous>) at new LinearGradientContainer (html2canvas.js:formatted:1374) at ImageLoader.loadImage (html2canvas.js:formatted:1256) at ImageLoader.<anonymous> (html2canvas.js:formatted:1227) at Array.forEach (<anonymous>) at ImageLoader.<anonymous> (html2canvas.js:formatted:1225) at Array.forEach (<anonymous>) at ImageLoader.findBackgroundImage (html2canvas.js:formatted:1219) at html2canvas.js:formatted:2563