fix ie 9 bug

This commit is contained in:
MoyuScript 2012-12-27 23:06:35 +02:00
parent 50f5d466dd
commit fa89e1b63d
4 changed files with 12 additions and 18 deletions

View File

@ -274,7 +274,9 @@ _html2canvas.Parse = function (images, options) {
text_align = text_align.replace(["-webkit-auto"],["auto"]); text_align = text_align.replace(["-webkit-auto"],["auto"]);
renderList = (!options.letterRendering && /^(left|right|justify|auto)$/.test(text_align) && noLetterSpacing(letter_spacing)) ? textNode.nodeValue.split(/(\b| )/) : textNode.nodeValue.split(""); renderList = (!options.letterRendering && /^(left|right|justify|auto)$/.test(text_align) && noLetterSpacing(letter_spacing))
? textNode.nodeValue.split(/(\b| )/)
: textNode.nodeValue.split("");
metrics = setTextVariables(ctx, el, text_decoration, color); metrics = setTextVariables(ctx, el, text_decoration, color);
oldTextNode = textNode; oldTextNode = textNode;
@ -307,7 +309,7 @@ _html2canvas.Parse = function (images, options) {
// it isn't supported, so let's wrap it inside an element instead and get the bounds there // it isn't supported, so let's wrap it inside an element instead and get the bounds there
// IE 9 bug // IE 9 bug
if (typeof oldTextNode.nodeValue !== "string" ){ if (!oldTextNode || typeof oldTextNode.nodeValue !== "string" ){
continue; continue;
} }
@ -326,7 +328,6 @@ _html2canvas.Parse = function (images, options) {
oldTextNode = newTextNode; oldTextNode = newTextNode;
parent.replaceChild(backupText, wrapElement); parent.replaceChild(backupText, wrapElement);
} }
if (textValue !== null) { if (textValue !== null) {
@ -1002,9 +1003,7 @@ _html2canvas.Parse = function (images, options) {
// skip hidden elements and their children // skip hidden elements and their children
if (getCSS(el, 'display') !== "none" && getCSS(el, 'visibility') !== "hidden" && !el.hasAttribute("data-html2canvas-ignore")) { if (getCSS(el, 'display') !== "none" && getCSS(el, 'visibility') !== "hidden" && !el.hasAttribute("data-html2canvas-ignore")) {
stack = renderElement(el, stack) || stack; stack = renderElement(el, stack) || stack;
ctx = stack.ctx; ctx = stack.ctx;
if (!ignoreElementsRegExp.test(el.nodeName)) { if (!ignoreElementsRegExp.test(el.nodeName)) {
@ -1012,15 +1011,14 @@ _html2canvas.Parse = function (images, options) {
i, i,
node, node,
childrenLen; childrenLen;
for (i = 0, childrenLen = elementChildren.length; i < childrenLen; i+=1) { for (i = 0, childrenLen = elementChildren.length; i < childrenLen; i+=1) {
node = elementChildren[i]; node = elementChildren[i];
if (node.nodeType === 1) { if (node.nodeType === 1) {
parseElement(node, stack); parseElement(node, stack);
} else if (node.nodeType === 3) { } else if (node.nodeType === 3) {
renderText(el, node, stack); renderText(el, node, stack);
} }
} }
} }
@ -1093,9 +1091,6 @@ _html2canvas.Parse = function (images, options) {
"</svg>" "</svg>"
].join(""); ].join("");
img.onload = function() { img.onload = function() {
stack.svgRender = img; stack.svgRender = img;
}; };
@ -1110,7 +1105,6 @@ _html2canvas.Parse = function (images, options) {
parseElement(children[i], stack); parseElement(children[i], stack);
} }
stack.backgroundColor = getCSS(document.documentElement, "backgroundColor"); stack.backgroundColor = getCSS(document.documentElement, "backgroundColor");
return stack; return stack;