ericdrowell/KineticJS — pull request #32 by boatmeme (2012-06-20 18:43:26+00:00)
Title: Calling stage.toJSON() prevents subsequent drawing on existing child layers

The bug re-producing code is here:

http://jsfiddle.net/BGkBq/

There should be 3 lines, but as you can see, only one is drawn.

If you call stage.toJSON(), you cannot subsequently draw() on child layers.

I tracked the bug down to the way attributes are being "copied" from the original node objects to the serialized objects. The problem is that the `var cleanAttrs` is an object reference to `node.attrs` and setting `cleanAttrs[key] = undefined`, actually alters the original `node.attrs[key]` value

My pull request changes the approach by selectively including instead of excluding attributes. This avoids the (presumably) unintended, bug-causing side effects.

Please let me know if you have any questions.

Fantastic work on the library, btw. The API is a joy to use.