mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Add SVG switch support (#1597)
SVG <switch> is simply parsed as a group because conditional attributes cannot be evaluated in paper.js context. Relates to #1389
This commit is contained in:
parent
33a5625936
commit
598d9a3356
2 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -143,6 +143,21 @@ test('Import SVG without insertion', function() {
|
|||
}, true);
|
||||
});
|
||||
|
||||
test('Import SVG switch', function(assert) {
|
||||
var done = assert.async();
|
||||
var svg = '<svg xmlns="http://www.w3.org/2000/svg"><switch><line x1="0" x2="10" y1="0" y2="10" fill="none"></line></switch></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, {
|
||||
|
|
Loading…
Reference in a new issue