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
- Updates CSS color stop regular expression to accept color names For review - TESTS COMING SOON. Also fixes some CSS2 linear gradients (Firefox). Ref niklasvh/html2canvas#469. — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients accept color names, CSS2-compatible syntax - Updates CSS color stop regular expression to accept color names - Handles arbitrary gradient direction percentages - Handles certain CSS2... — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients accept color names, CSS2-compatible syntax - Updates CSS color stop regular expression to accept color names - Handles arbitrary gradient direction percentages - Handles certain CSS2... — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients accept color names, CSS2-compatible syntax - Updates CSS color stop regular expression to accept color names - Handles arbitrary gradient direction percentages - Handles certain CSS2... — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients now parse color names Also: - Cleans up color stop and linear gradient regular expressions. - Handles percentage-based linear gradient positions (fixes Firefox). Fixes niklasvh/html... — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients now parse color names Also: - Cleans up color stop and linear gradient regular expressions. - Handles percentage-based linear gradient positions (fixes Firefox). Fixes niklasvh/html... — committed to usmonster/html2canvas by usmonster 9 years ago
- Correctly handle named colors in gradients — committed to niklasvh/html2canvas by niklasvh 9 years ago
- Linear gradients now parse color names Also: - Cleans up color stop and linear gradient regular expressions. - Handles percentage-based linear gradient positions (fixes Firefox). Fixes niklasvh/html... — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients now parse color names Also: - Cleans up color stop and linear gradient regular expressions. - Handles percentage-based linear gradient positions (fixes Firefox). Fixes niklasvh/html... — committed to usmonster/html2canvas by usmonster 9 years ago
- Linear gradients now parse color names Also: - Cleans up color stop and linear gradient regular expressions. - Handles percentage-based linear gradient positions (fixes Firefox). Fixes niklasvh/html... — committed to usmonster/html2canvas by usmonster 9 years ago
@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