Merge pull request #35 from cobexer/small-fixes

Small fixes
This commit is contained in:
Niklas von Hertzen 2011-11-26 10:14:00 -08:00
commit 097a4e58d7
3 changed files with 24 additions and 12 deletions

View File

@ -36,8 +36,6 @@ html2canvas.Util.backgroundImage = function (src) {
};
html2canvas.Util.Bounds = function getBounds (el) {
window.scroll(0,0);
var clientRect,
bounds = {};
@ -109,9 +107,9 @@ html2canvas.Util.getCSS = function (el, attribute) {
if ( rsLeft ) {
el.runtimeStyle.left = rsLeft;
}*/
val = $(el).css(attribute);
// val = $(el).css(attribute);
// }
return val;
return $(el).css(attribute);
};
@ -128,5 +126,12 @@ html2canvas.Util.Extend = function (options, defaults) {
html2canvas.Util.Children = function(el) {
// $(el).contents() !== el.childNodes, Opera / IE have issues with that
return $(el).contents();
var children;
try {
children = $(el).contents();
} catch (ex) {
html2canvas.log("html2canvas.Util.Children failed with exception: " + ex.message);
children = [];
}
return children;
}

View File

@ -11,7 +11,7 @@
*/
html2canvas.Parse = function (element, images, opts) {
window.scroll(0,0);
opts = opts || {};
// select body by default
@ -175,14 +175,14 @@ html2canvas.Parse = function (element, images, opts) {
// TODO add another image
img.src = "http://html2canvas.hertzen.com/images/8.jpg";
// http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever (handtinywhite.gif)
img.src = "data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=";
img.width = 1;
img.height = 1;
img.style.margin = 0;
img.style.padding = 0;
img.style.verticalAlign = "baseline";
span.style.fontFamily = font;
span.style.fontSize = fontSize;

View File

@ -156,7 +156,8 @@ html2canvas.Preload = function(element, opts){
contentsLen = contents.length,
background_image,
src,
img;
img,
elNodeType = false;
for (i = 0; i < contentsLen; i+=1 ){
// var ignRe = new RegExp("("+this.ignoreElements+")");
@ -166,8 +167,14 @@ html2canvas.Preload = function(element, opts){
}
// }
if (el.nodeType === 1 || el.nodeType === undefined){
try {
elNodeType = el.nodeType;
} catch (ex) {
elNodeType = false;
html2canvas.log("html2canvas: failed to access some element's nodeType - Exception: " + ex.message);
}
if (elNodeType === 1 || elNodeType === undefined){
background_image = html2canvas.Util.getCSS(el, 'backgroundImage');