SVGImport: Inherit default styles on Node.js too.

This commit is contained in:
Jürg Lehni 2016-02-11 11:20:32 +01:00
parent df57c4adb9
commit e38a33fd64
2 changed files with 10 additions and 11 deletions

View file

@ -16,7 +16,8 @@
"main": "dist/paper-full.js", "main": "dist/paper-full.js",
"scripts": { "scripts": {
"lint": "jshint src", "lint": "jshint src",
"prepublish": "gulp minify" "prepublish": "gulp minify",
"test": "gulp test"
}, },
"files": [ "files": [
"AUTHORS.md", "AUTHORS.md",

View file

@ -567,22 +567,20 @@ new function() {
rootSize = getSize(node, null, null, true) rootSize = getSize(node, null, null, true)
|| paper.getView().getSize(); || paper.getView().getSize();
// We need to move the SVG node to the current document, so default // We need to move the SVG node to the current document, so default
// styles apply! For this we create and insert a temporary SVG // styles are correctly inherited! For this we create and insert a
// container which is removed again at the end. This container also // temporary SVG container which is removed again at the end. This
// helps fix a bug on IE. No need to inherit styles on Node.js // container also helps fix a bug on IE.
container = !paper.agent.node && SvgElement.create('svg', { container = SvgElement.create('svg', {
// If no stroke-width is set, IE/Edge appears to have a // If no stroke-width is set, IE/Edge appears to have a
// default of 0.01px. We can set a default style on the // default of 0.01px. We can set a default style on the
// parent container as a more sensible fall-back. Also, browsers // parent container as a more sensible fall-back. Also, browsers
// have a default miter-limit of 4, while Paper.js has 10 // have a default miter-limit of 4, while Paper.js has 10
style: 'stroke-width: 1px; stroke-miterlimit: 10' style: 'stroke-width: 1px; stroke-miterlimit: 10'
}); });
if (container) { parent = node.parentNode;
body.appendChild(container); next = node.nextSibling;
parent = node.parentNode; container.appendChild(node);
next = node.nextSibling; body.appendChild(container);
container.appendChild(node);
}
} }
// Have items imported from SVG not bake in all transformations to their // 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 // content and children, as this is how SVG works too, but preserve the