fixed IE 9 text issues

This commit is contained in:
MoyuScript
2011-08-11 16:19:42 +03:00
parent 08558034b4
commit 7880e62056
4 changed files with 23 additions and 13 deletions

View File

@ -74,8 +74,13 @@ html2canvas.prototype.newText = function(el,textNode,stack,form){
var oldTextNode = textNode;
for(var c=0;c<renderList.length;c++){
// IE 9 bug
if (typeof oldTextNode.nodeValue != "string"){
continue;
}
// TODO only do the splitting for non-range prints
var newTextNode = oldTextNode.splitText(renderList[c].length);
if (text_decoration!="none" || this.trim(oldTextNode.nodeValue).length != 0){
@ -99,7 +104,7 @@ html2canvas.prototype.newText = function(el,textNode,stack,form){
}
}else{
// it isn't supported, so let's wrap it inside an element instead and the bounds there
var parent = oldTextNode.parentNode;
var wrapElement = document.createElement('wrapper');
var backupText = oldTextNode.cloneNode(true);
@ -107,7 +112,6 @@ html2canvas.prototype.newText = function(el,textNode,stack,form){
parent.replaceChild(wrapElement,oldTextNode);
var bounds = this.getBounds(wrapElement);
parent.replaceChild(backupText,wrapElement);
}

View File

@ -52,6 +52,7 @@ html2canvas.prototype.getBounds = function(el){
// need to create new object, as clientrect bounds can't be modified, thanks pufuwozu
// TODO add scroll position to bounds, so no scrolling of window necessary
bounds.top = clientRect.top;
bounds.bottom = clientRect.bottom || (clientRect.top + clientRect.height);
bounds.left = clientRect.left;
bounds.width = clientRect.width;
bounds.height = clientRect.height;