I've an Object which contains circular references in it (references to DOM nodes). I've to save this object in local or session storage. To do this I was trying to do JSON.stringify
and because of circular references I'm unable to stringify it.
This is how I'm getting the object that I've to save.
var elements = $("#content").children().detach();
After doing some research online most of the people suggested using cycle.js.
So I've tried using the cycle.js on elements variable, which will decycle the circular reference object. I've also tried circular-json.js, stringify-object.js
All these are throwing an Maximum call stack size exceeded error. I don't understand why I'm getting this error and how I could fix it.
Is there a way to get around this and save the object?