Skip to content

Commit 8d3a0c2

Browse files
committed
cache computed style
1 parent 16022b8 commit 8d3a0c2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Core.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"use strict";
99

1010
var _html2canvas = {},
11+
previousElement,
12+
computedCSS,
1113
html2canvas;
1214

1315

@@ -106,7 +108,10 @@ _html2canvas.Util.getCSS = function (el, attribute) {
106108

107109

108110
if ( window.getComputedStyle ) {
109-
val = document.defaultView.getComputedStyle(el, null)[ attribute ];
111+
if ( previousElement !== el ) {
112+
computedCSS = document.defaultView.getComputedStyle(el, null);
113+
}
114+
val = computedCSS[ attribute ];
110115

111116
if ( attribute === "backgroundPosition" ) {
112117

0 commit comments

Comments
 (0)