diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index 829d7b19..2deb2b8c 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -303,7 +303,11 @@ new function() { getPoint(node, 'dx', 'dy'))); text.setContent(node.textContent.trim() || ''); return text; - } + }, + + // https://www.w3.org/TR/SVG/struct.html#SwitchElement + // Conditional attributes are ignored and all children are rendered. + switch: importGroup }; // Attributes and Styles diff --git a/test/tests/SvgImport.js b/test/tests/SvgImport.js index a0c3e261..fbd13ff2 100644 --- a/test/tests/SvgImport.js +++ b/test/tests/SvgImport.js @@ -143,6 +143,21 @@ test('Import SVG without insertion', function() { }, true); }); +test('Import SVG switch', function(assert) { + var done = assert.async(); + var svg = ''; + paper.project.importSVG(svg, { + onLoad: function(item) { + equals(item.className, 'Group'); + equals(item.children.length, 1); + equals(item.firstChild.className, 'Group'); + equals(item.firstChild.children.length, 1); + equals(item.firstChild.firstChild, new Path([new Point(0, 0), new Point(10, 10)])); + done(); + } + }); +}); + function importSVG(assert, url, message, options) { var done = assert.async(); project.importSVG(url, {