diff --git a/src/Stage.js b/src/Stage.js index b521576f..2bd518c3 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -163,18 +163,16 @@ Kinetic.Stage.prototype = { function addNode(node) { var obj = {}; - var cleanAttrs = node.attrs; + obj.attrs = {}; - // remove function, image, DOM, and objects with methods - for(var key in cleanAttrs) { - var val = cleanAttrs[key]; - if(go._isFunction(val) || go._isElement(val) || go._hasMethods(val)) { - cleanAttrs[key] = undefined; + // serialize only attributes that are not function, image, DOM, or objects with methods + for(var key in node.attrs) { + var val = node.attrs[key]; + if(!go._isFunction(val) && !go._isElement(val) && !go._hasMethods(val)) { + obj.attrs[key] = val; } } - obj.attrs = cleanAttrs; - obj.nodeType = node.nodeType; obj.shapeType = node.shapeType;