{"action":"closed","issue":{"url":"https://api.github.com/repos/kangax/fabric.js/issues/2598","labels_url":"https://api.github.com/repos/kangax/fabric.js/issues/2598/labels{/name}","comments_url":"https://api.github.com/repos/kangax/fabric.js/issues/2598/comments","events_url":"https://api.github.com/repos/kangax/fabric.js/issues/2598/events","html_url":"https://github.com/kangax/fabric.js/issues/2598","id":114513739,"number":2598,"title":"Cloning SVG loaded objects","user":{"login":"dud3","id":5823644,"avatar_url":"https://avatars.githubusercontent.com/u/5823644?v=3","gravatar_id":"","url":"https://api.github.com/users/dud3","html_url":"https://github.com/dud3","followers_url":"https://api.github.com/users/dud3/followers","following_url":"https://api.github.com/users/dud3/following{/other_user}","gists_url":"https://api.github.com/users/dud3/gists{/gist_id}","starred_url":"https://api.github.com/users/dud3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dud3/subscriptions","organizations_url":"https://api.github.com/users/dud3/orgs","repos_url":"https://api.github.com/users/dud3/repos","events_url":"https://api.github.com/users/dud3/events{/privacy}","received_events_url":"https://api.github.com/users/dud3/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kangax/fabric.js/labels/bug","name":"bug","color":"e10c02"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-11-02T02:42:28Z","updated_at":"2015-11-02T13:33:57Z","closed_at":"2015-11-02T13:33:57Z","body":"## Problem space\r\nWhen cloning a `SVG loaded object` changes applied to the `parent object` will be applied to the `cloned object` as well.\r\n\r\nE.x.: If fill-color of a path is applied to the `parent object` it gets applied to `cloned object` as well.\r\n\r\nSo the: `parent object` means the object that clone got created from.\r\n\r\n## Example\r\nLoad the svg file:\r\n```js\r\nvar loadSvg = function() {\r\n  var url = 'path/to/file.svg';\r\n  fabric.loadSVGFromURL(url, function (objects, options) {\r\n    var obj = fabric.util.groupSVGElements(objects, options);\r\n    var group = new fabric.Group(object.getObjects(), {originX:  'center', originY: 'center', centeredScaling: true, hasControls: true });\r\n    canvas.add(group);\r\n    canvas.renderAll();\r\n  });\r\n}\r\n```\r\n\r\nSimple clone function:\r\n```js\r\nvar cloneObj = function()\r\n  var aobj = canvas.getActiveOjbect();\r\n  var clone = fabric.util[\"object\"].clone(aobj);\r\n  canvas.add(clone);\r\n  canvas.renderAll();\r\n}\r\n```\r\n\r\n## Note\r\nOne thing I've noticed is that:\r\nThe objects that got loaded from `loadSVGFromURL` get unique `svgUid`, I guess it increments from the last loaded SVG file.\r\n\r\nWhen cloned the `svgUid` does NOT increment, it is the same as the `parent object svgUid`."}}