From 2d39cd0719f9be732256d7a258124c76e85a8620 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 4 Aug 2013 15:41:00 +0300 Subject: [PATCH] fix shadow parsing for IE9 --- src/Core.js | 3 +-- src/Parse.js | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Core.js b/src/Core.js index 9caaa5c..0bfadb7 100644 --- a/src/Core.js +++ b/src/Core.js @@ -21,12 +21,11 @@ _html2canvas.Util.trimText = (function(isNative){ })( String.prototype.trim ); (function() { - // TODO: support all possible length values var TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g; var TEXT_SHADOW_VALUES = /(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g; _html2canvas.Util.parseTextShadows = function (value) { - if (value === 'none') { + if (!value || value === 'none') { return []; } diff --git a/src/Parse.js b/src/Parse.js index 74951ac..b594d0d 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -80,7 +80,7 @@ _html2canvas.Parse = function (images, options) { bold = getCSS(el, "fontWeight"), family = getCSS(el, "fontFamily"), size = getCSS(el, "fontSize"), - shadow = getCSS(el, "textShadow"); + shadows = _html2canvas.Util.parseTextShadows(getCSS(el, "textShadow")); switch(parseInt(bold, 10)){ case 401: @@ -95,9 +95,7 @@ _html2canvas.Parse = function (images, options) { ctx.setVariable("font", [getCSS(el, "fontStyle"), getCSS(el, "fontVariant"), bold, size, family].join(" ")); ctx.setVariable("textAlign", (align) ? "right" : "left"); - if (shadow !== "none") { - var shadows = _html2canvas.Util.parseTextShadows(shadow); - + if (shadows.length) { // TODO: support multiple text shadows // apply the first text shadow ctx.setVariable("shadowColor", shadows[0].color);