From e38a33fd643da26e4a002aad598f18e6481b1a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 11 Feb 2016 11:20:32 +0100 Subject: [PATCH] SVGImport: Inherit default styles on Node.js too. --- package.json | 3 ++- src/svg/SvgImport.js | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 88cd21bc..475c7a1d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "main": "dist/paper-full.js", "scripts": { "lint": "jshint src", - "prepublish": "gulp minify" + "prepublish": "gulp minify", + "test": "gulp test" }, "files": [ "AUTHORS.md", diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index fd213005..2739cbbb 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -567,22 +567,20 @@ new function() { rootSize = getSize(node, null, null, true) || paper.getView().getSize(); // We need to move the SVG node to the current document, so default - // styles apply! For this we create and insert a temporary SVG - // container which is removed again at the end. This container also - // helps fix a bug on IE. No need to inherit styles on Node.js - container = !paper.agent.node && SvgElement.create('svg', { + // styles are correctly inherited! For this we create and insert a + // temporary SVG container which is removed again at the end. This + // container also helps fix a bug on IE. + container = SvgElement.create('svg', { // If no stroke-width is set, IE/Edge appears to have a // default of 0.01px. We can set a default style on the // parent container as a more sensible fall-back. Also, browsers // have a default miter-limit of 4, while Paper.js has 10 style: 'stroke-width: 1px; stroke-miterlimit: 10' }); - if (container) { - body.appendChild(container); - parent = node.parentNode; - next = node.nextSibling; - container.appendChild(node); - } + parent = node.parentNode; + next = node.nextSibling; + container.appendChild(node); + body.appendChild(container); } // Have items imported from SVG not bake in all transformations to their // content and children, as this is how SVG works too, but preserve the