Merge pull request #37 from gatapia/patch-2

Fix for gradient parsing (when step positions are specified)
This commit is contained in:
Niklas von Hertzen 2011-12-07 06:13:35 -08:00
commit 753ab77ef6

View File

@ -31,7 +31,7 @@ html2canvas.Generate.Gradient = function(src, bounds) {
canvas.height = bounds.height;
function getColors(input) {
function getColors(input) {
var j = -1,
color = '',
chr;
@ -39,16 +39,20 @@ html2canvas.Generate.Gradient = function(src, bounds) {
while( j++ < input.length ) {
chr = input.charAt( j );
if (chr === ')') {
color += chr;
color += chr;
steps.push( color );
color = '';
j+=2;
} else {
} else if (color || isValidColorStartChar(chr)) {
color += chr;
}
}
}
function isValidColorStartChar(c) {
return c && /[^0-9%,]/.test(c);
}
if ( tmp = src.match(/-webkit-linear-gradient\((.*)\)/) ) {
position = tmp[1].split( ",", 1 )[0];