From eefac2c9cb13b7faef86599700fb9bd476fa90bc Mon Sep 17 00:00:00 2001 From: aebabis Date: Fri, 2 Aug 2019 20:12:06 -0700 Subject: [PATCH] Removing margin on clone of root node This makes it so that elements with negative margin are not cropped by the SVG --- src/dom-to-image.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dom-to-image.js b/src/dom-to-image.js index 27201ac9..77b625b0 100644 --- a/src/dom-to-image.js +++ b/src/dom-to-image.js @@ -229,6 +229,11 @@ function cloneStyle() { copyStyle(window.getComputedStyle(original), clone.style); + + // Prevent cropping and gaps at edge of element + if (root) { + clone.style.setProperty('margin', 0); + } function copyStyle(source, target) { if (source.cssText) target.cssText = source.cssText;