Skip to content

Commit 134f499

Browse files
SNDST00M: M.U.N.I.NIDisposable
authored andcommitted
Fix container size and reduce styling further
1 parent 0761149 commit 134f499

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/dom-to-image-more.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function(global) {
1+
(function(window) {
22
'use strict';
33

44
var util = newUtil();
@@ -35,7 +35,7 @@
3535
if (typeof exports === "object" && typeof module === "object")
3636
module.exports = domtoimage;
3737
else
38-
global.domtoimage = domtoimage;
38+
window.domtoimage = domtoimage;
3939

4040
/**
4141
* @param {Node} node - The DOM Node object to render
@@ -261,7 +261,7 @@
261261
});
262262

263263
function cloneStyle() {
264-
copyStyle(getUserComputedStyle(original), clone.style);
264+
copyStyle(getUserComputedStyle(original, root), clone.style);
265265

266266
function copyFont(source, target) {
267267
target.font = source.font;
@@ -314,7 +314,7 @@
314314
});
315315

316316
function clonePseudoElement(element) {
317-
var style = getUserComputedStyle(original, element);
317+
var style = window.getComputedStyle(original, element);
318318
var content = style.getPropertyValue('content');
319319

320320
if (content === '' || content === 'none') return;
@@ -469,7 +469,7 @@
469469

470470
function toBlob(canvas) {
471471
return new Promise(function(resolve) {
472-
var binaryString = global.atob(canvas.toDataURL().split(',')[1]);
472+
var binaryString = window.atob(canvas.toDataURL().split(',')[1]);
473473
var length = binaryString.length;
474474
var binaryArray = new Uint8Array(length);
475475

@@ -637,7 +637,7 @@
637637
}
638638

639639
function px(node, styleProperty) {
640-
var value = getUserComputedStyle(node).getPropertyValue(styleProperty);
640+
var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
641641
return parseFloat(value.replace('px', ''));
642642
}
643643
}
@@ -843,8 +843,8 @@
843843
}
844844
}
845845

846-
function getUserComputedStyle(element, pseudo) {
847-
var computedStyles = global.getComputedStyle(element, pseudo);
846+
function getUserComputedStyle(element, root) {
847+
var computedStyles = window.getComputedStyle(element);
848848
var inlineStyles = element.style;
849849

850850
if (pseudo) {
@@ -857,7 +857,7 @@
857857
var inlineValue = inlineStyles.getPropertyValue(key);
858858

859859
if (!inlineValue.length) {
860-
inlineStyles.setProperty(key, 'initial');
860+
inlineStyles.setProperty(key, root ? 'initial' : 'unset');
861861

862862
var initialValue = computedStyles.getPropertyValue(key);
863863

0 commit comments

Comments
 (0)