From b6e48ad8d8a5bb62308222113ae046c3baf7569b Mon Sep 17 00:00:00 2001 From: Jarda Kotesovec Date: Fri, 29 May 2015 17:03:27 +0200 Subject: [PATCH] SVG Import defs first --- src/svg/SVGImport.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/svg/SVGImport.js b/src/svg/SVGImport.js index 4c1f1894..0c35905b 100644 --- a/src/svg/SVGImport.js +++ b/src/svg/SVGImport.js @@ -87,6 +87,14 @@ new function() { // items and avoid calling applyAttributes() again. project._currentStyle = item._style.clone(); } + // Put defs first, Affinity designer exports defs as last + if (isRoot) { + var defsNodes = [], otherNodes = []; + for (var i = 0, l = nodes.length; i < l; i++) { + nodes[i].nodeName.toLowerCase() === 'defs' ? defsNodes.push(nodes[i]) : otherNodes.push(nodes[i]); + } + nodes = defsNodes.concat(otherNodes); + } // Collect the children in an array and apply them all at once. for (var i = 0, l = nodes.length; i < l; i++) { var childNode = nodes[i],