mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
Merge pull request #32 from boatmeme/11a1662c0e3e8c9bd20db2ac8ff3f2572b337cb7
Calling stage.toJSON() prevents subsequent drawing on existing child layers
This commit is contained in:
14
src/Stage.js
14
src/Stage.js
@@ -163,18 +163,16 @@ Kinetic.Stage.prototype = {
|
|||||||
function addNode(node) {
|
function addNode(node) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
var cleanAttrs = node.attrs;
|
obj.attrs = {};
|
||||||
|
|
||||||
// remove function, image, DOM, and objects with methods
|
// serialize only attributes that are not function, image, DOM, or objects with methods
|
||||||
for(var key in cleanAttrs) {
|
for(var key in node.attrs) {
|
||||||
var val = cleanAttrs[key];
|
var val = node.attrs[key];
|
||||||
if(go._isFunction(val) || go._isElement(val) || go._hasMethods(val)) {
|
if(!go._isFunction(val) && !go._isElement(val) && !go._hasMethods(val)) {
|
||||||
cleanAttrs[key] = undefined;
|
obj.attrs[key] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.attrs = cleanAttrs;
|
|
||||||
|
|
||||||
obj.nodeType = node.nodeType;
|
obj.nodeType = node.nodeType;
|
||||||
obj.shapeType = node.shapeType;
|
obj.shapeType = node.shapeType;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user