mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
parent
d68239a541
commit
519898357f
1 changed files with 18 additions and 8 deletions
|
@ -175,21 +175,31 @@ new function() {
|
||||||
// nodeNames still.
|
// nodeNames still.
|
||||||
var importers = {
|
var importers = {
|
||||||
'#document': function (node, type, options, isRoot) {
|
'#document': function (node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes,
|
var nodes = node.childNodes;
|
||||||
move = !paper.agent.node;
|
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
var child = nodes[i],
|
var child = nodes[i],
|
||||||
next;
|
next;
|
||||||
if (child.nodeType === 1) {
|
if (child.nodeType === 1) {
|
||||||
if (move) {
|
// NOTE: We need to move the SVG node to the current
|
||||||
// NOTE: We need to move the svg node into our current
|
// document, so default styles apply! For this we create and
|
||||||
// document, so default styles apply!
|
// insert a temporary SVG parent node which is removed again
|
||||||
|
// at the end. This parent node also helps fix a bug on IE.
|
||||||
|
var body = document.body,
|
||||||
|
// No need to inherit styles on Node.js
|
||||||
|
parent = !paper.agent.node && SVGNode.create('svg');
|
||||||
|
if (parent) {
|
||||||
|
body.appendChild(parent);
|
||||||
|
// 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.
|
||||||
|
parent.style.strokeWidth = '1px';
|
||||||
next = child.nextSibling;
|
next = child.nextSibling;
|
||||||
document.body.appendChild(child);
|
parent.appendChild(child);
|
||||||
}
|
}
|
||||||
var item = importSVG(child, options, isRoot);
|
var item = importSVG(child, options, isRoot);
|
||||||
if (move) {
|
if (parent) {
|
||||||
// After import, we move it back to where it was:
|
// After import, move things back to how they were:
|
||||||
|
body.removeChild(parent);
|
||||||
if (next) {
|
if (next) {
|
||||||
node.insertBefore(child, next);
|
node.insertBefore(child, next);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue