|
1 |
| -(function(global) { |
| 1 | +(function(window) { |
2 | 2 | 'use strict';
|
3 | 3 |
|
4 | 4 | var util = newUtil();
|
|
35 | 35 | if (typeof exports === "object" && typeof module === "object")
|
36 | 36 | module.exports = domtoimage;
|
37 | 37 | else
|
38 |
| - global.domtoimage = domtoimage; |
| 38 | + window.domtoimage = domtoimage; |
39 | 39 |
|
40 | 40 | /**
|
41 | 41 | * @param {Node} node - The DOM Node object to render
|
|
261 | 261 | });
|
262 | 262 |
|
263 | 263 | function cloneStyle() {
|
264 |
| - copyStyle(getUserComputedStyle(original), clone.style); |
| 264 | + copyStyle(getUserComputedStyle(original, root), clone.style); |
265 | 265 |
|
266 | 266 | function copyFont(source, target) {
|
267 | 267 | target.font = source.font;
|
|
314 | 314 | });
|
315 | 315 |
|
316 | 316 | function clonePseudoElement(element) {
|
317 |
| - var style = getUserComputedStyle(original, element); |
| 317 | + var style = window.getComputedStyle(original, element); |
318 | 318 | var content = style.getPropertyValue('content');
|
319 | 319 |
|
320 | 320 | if (content === '' || content === 'none') return;
|
|
469 | 469 |
|
470 | 470 | function toBlob(canvas) {
|
471 | 471 | return new Promise(function(resolve) {
|
472 |
| - var binaryString = global.atob(canvas.toDataURL().split(',')[1]); |
| 472 | + var binaryString = window.atob(canvas.toDataURL().split(',')[1]); |
473 | 473 | var length = binaryString.length;
|
474 | 474 | var binaryArray = new Uint8Array(length);
|
475 | 475 |
|
|
637 | 637 | }
|
638 | 638 |
|
639 | 639 | function px(node, styleProperty) {
|
640 |
| - var value = getUserComputedStyle(node).getPropertyValue(styleProperty); |
| 640 | + var value = window.getComputedStyle(node).getPropertyValue(styleProperty); |
641 | 641 | return parseFloat(value.replace('px', ''));
|
642 | 642 | }
|
643 | 643 | }
|
|
843 | 843 | }
|
844 | 844 | }
|
845 | 845 |
|
846 |
| - function getUserComputedStyle(element, pseudo) { |
847 |
| - var computedStyles = global.getComputedStyle(element, pseudo); |
| 846 | + function getUserComputedStyle(element, root) { |
| 847 | + var computedStyles = window.getComputedStyle(element); |
848 | 848 | var inlineStyles = element.style;
|
849 | 849 |
|
850 | 850 | if (pseudo) {
|
|
857 | 857 | var inlineValue = inlineStyles.getPropertyValue(key);
|
858 | 858 |
|
859 | 859 | if (!inlineValue.length) {
|
860 |
| - inlineStyles.setProperty(key, 'initial'); |
| 860 | + inlineStyles.setProperty(key, root ? 'initial' : 'unset'); |
861 | 861 |
|
862 | 862 | var initialValue = computedStyles.getPropertyValue(key);
|
863 | 863 |
|
|
0 commit comments