mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-02 19:14:42 +00:00
Fix leaking of one element's attribute values onto another (following) element during SVG parsing.
This commit is contained in:
parent
7a28d275a3
commit
5c7440cc13
4 changed files with 9 additions and 13 deletions
2
dist/all.js
vendored
2
dist/all.js
vendored
|
|
@ -7962,7 +7962,7 @@ fabric.util.animate = animate;
|
|||
var parsedAttributes = fabric.parseAttributes(element, fabric.Rect.ATTRIBUTE_NAMES);
|
||||
parsedAttributes = _setDefaultLeftTopValues(parsedAttributes);
|
||||
|
||||
var rect = new fabric.Rect(fabric.util.object.extend(options || { }, parsedAttributes));
|
||||
var rect = new fabric.Rect(fabric.util.object.extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes));
|
||||
rect._normalizeLeftTopProperties(parsedAttributes);
|
||||
|
||||
return rect;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@
|
|||
var parsedAttributes = fabric.parseAttributes(element, fabric.Rect.ATTRIBUTE_NAMES);
|
||||
parsedAttributes = _setDefaultLeftTopValues(parsedAttributes);
|
||||
|
||||
var rect = new fabric.Rect(fabric.util.object.extend(options || { }, parsedAttributes));
|
||||
var rect = new fabric.Rect(fabric.util.object.extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes));
|
||||
rect._normalizeLeftTopProperties(parsedAttributes);
|
||||
|
||||
return rect;
|
||||
|
|
|
|||
3
test/fixtures/svg_with_rect.svg
vendored
3
test/fixtures/svg_with_rect.svg
vendored
|
|
@ -3,5 +3,6 @@
|
|||
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
|
||||
]>
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="8.5" y="208" width="8.76" height="17.28" />
|
||||
<rect height="100" width="100" y="50" x="50" fill="red" />
|
||||
<circle r="25" cy="100" cx="100" fill="green" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 379 B |
|
|
@ -253,34 +253,29 @@
|
|||
var path = data[0];
|
||||
|
||||
ok(path instanceof fabric.Path);
|
||||
equals(EXPECTED_PATH_JSON, JSON.stringify(path.toJSON()));
|
||||
equals(JSON.stringify(path.toJSON()), EXPECTED_PATH_JSON);
|
||||
}
|
||||
start();
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
// https://github.com/kangax/fabric.js/issues/25
|
||||
asyncTest('parseSVGDocument w. rect', function() {
|
||||
asyncTest('parsing one element should not "leak" its "fill" value onto parsing of following element', function() {
|
||||
|
||||
var data;
|
||||
var objects;
|
||||
fabric.util.request('../fixtures/svg_with_rect.svg', {
|
||||
method: 'get',
|
||||
onComplete: function(resp) {
|
||||
var doc = resp.responseXML;
|
||||
fabric.parseSVGDocument(doc.documentElement, function() {
|
||||
data = arguments[0];
|
||||
objects = arguments[0];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
equals(typeof data, 'object');
|
||||
equals(data.length, 1);
|
||||
equals(objects[1].fill, 'green');
|
||||
|
||||
if (data) {
|
||||
var rect = data[0];
|
||||
ok(rect instanceof fabric.Rect);
|
||||
}
|
||||
start();
|
||||
}, 1500);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue