Skip to content

Commit 2bb926c

Browse files
committed
Fix webkit-gradient() parsing
1 parent 861a18f commit 2bb926c

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/Generate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@
324324
if(bounds.width === 0 || bounds.height === 0) {
325325
return;
326326
}
327-
327+
328328
var canvas = document.createElement('canvas'),
329329
ctx = canvas.getContext('2d'),
330330
gradient, grad, i, len;
@@ -378,7 +378,7 @@
378378
canvasRadial.width = canvasRadial.height = di;
379379

380380
grad = ctxRadial.createRadialGradient(gradient.rx, gradient.ry, 0, gradient.rx, gradient.ry, ri);
381-
381+
382382
for (i = 0, len = gradient.colorStops.length; i < len; i+=1) {
383383
try {
384384
grad.addColorStop(gradient.colorStops[i].stop, gradient.colorStops[i].color);

src/Parse.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,10 @@ _html2canvas.Parse = function (images, options) {
818818
function renderBackgroundImage(element, bounds, ctx) {
819819
var backgroundImage = getCSS(element, "backgroundImage"),
820820
backgroundImages = _html2canvas.Util.parseBackgroundImage(backgroundImage),
821-
image;
821+
image,
822+
imageIndex = backgroundImages.length;
822823

823-
for(var imageIndex = backgroundImages.length; imageIndex-- > 0;) {
824+
while(imageIndex--) {
824825
backgroundImage = backgroundImages[imageIndex];
825826

826827
if (!backgroundImage.args || backgroundImage.args.length === 0) {
@@ -829,15 +830,15 @@ _html2canvas.Parse = function (images, options) {
829830

830831
var key = backgroundImage.method === 'url' ?
831832
backgroundImage.args[0] :
832-
backgroundImage.value + '/' + element.__html2canvas__id + '/' + imageIndex;
833+
backgroundImage.value;
833834

834835
image = loadImage(key);
835836

836837
// TODO add support for background-origin
837838
if (image) {
838839
renderBackgroundRepeating(element, bounds, ctx, image, imageIndex);
839840
} else {
840-
h2clog("html2canvas: Error loading background:" + backgroundImage);
841+
h2clog("html2canvas: Error loading background:", backgroundImage);
841842
}
842843
}
843844
}

src/Preload.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,15 @@ _html2canvas.Preload = function( options ) {
139139
src = background_image.args[0];
140140
methods.loadImage(src);
141141

142-
} else if( background_image.method.match( /\-gradient$/ ) ) {
142+
} else if( background_image.method.match( /\-?gradient$/ ) ) {
143143
if(bounds === undefined) {
144144
bounds = _html2canvas.Util.Bounds( el );
145145
}
146146

147-
var key = background_image.value + '/' + el.__html2canvas__id + '/' + imageIndex;
148147
img = _html2canvas.Generate.Gradient( background_image.value, bounds);
149148

150149
if ( img !== undefined ){
151-
images[ key ] = {
150+
images[background_image.value] = {
152151
img: img,
153152
succeeded: true
154153
};

0 commit comments

Comments
 (0)