From 8d3a0c2b0ddf9a964a000f361f17606d7ec0c4eb Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 24 May 2012 14:10:40 +0300 Subject: [PATCH] cache computed style --- src/Core.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Core.js b/src/Core.js index 86e1a73..77ac27c 100644 --- a/src/Core.js +++ b/src/Core.js @@ -8,6 +8,8 @@ "use strict"; var _html2canvas = {}, +previousElement, +computedCSS, html2canvas; @@ -106,7 +108,10 @@ _html2canvas.Util.getCSS = function (el, attribute) { if ( window.getComputedStyle ) { - val = document.defaultView.getComputedStyle(el, null)[ attribute ]; + if ( previousElement !== el ) { + computedCSS = document.defaultView.getComputedStyle(el, null); + } + val = computedCSS[ attribute ]; if ( attribute === "backgroundPosition" ) {