From 4ce8b8f655f3ff26a749df66ede3c0a9cd72409a Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 10 Jan 2018 13:56:49 -0500 Subject: [PATCH] Do not change properties on bbox directly it throws errors in edge. --- src/svg-quirks-mode/svg-renderer.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/svg-quirks-mode/svg-renderer.js b/src/svg-quirks-mode/svg-renderer.js index ccf09e3..5b6147c 100644 --- a/src/svg-quirks-mode/svg-renderer.js +++ b/src/svg-quirks-mode/svg-renderer.js @@ -256,17 +256,22 @@ class SvgRenderer { // This may have false-positives, but at least the bbox will always // contain the full graphic including strokes. const halfStrokeWidth = this._findLargestStrokeWidth(this._svgTag) / 2; - bbox.width += halfStrokeWidth * 2; - bbox.height += halfStrokeWidth * 2; - bbox.x -= halfStrokeWidth; - bbox.y -= halfStrokeWidth; + const width = bbox.width + (halfStrokeWidth * 2); + const height = bbox.height + (halfStrokeWidth * 2); + const x = bbox.x - halfStrokeWidth; + const y = bbox.y - halfStrokeWidth; // Set the correct measurements on the SVG tag, and save them. - this._svgTag.setAttribute('width', bbox.width); - this._svgTag.setAttribute('height', bbox.height); + this._svgTag.setAttribute('width', width); + this._svgTag.setAttribute('height', height); this._svgTag.setAttribute('viewBox', - `${bbox.x} ${bbox.y} ${bbox.width} ${bbox.height}`); - this._measurements = bbox; + `${x} ${y} ${width} ${height}`); + this._measurements = { + width: width, + height: height, + x: x, + y: y + }; } /**