Hybrid View
-
18 Nov 2011 6:57 AM #1
Ext.clone should check for a custom clone(), _clone() or another suitable method
Ext.clone should check for a custom clone(), _clone() or another suitable method
I have faced infinite recursion errors multiple times with Ext.clone trying to clone an object which contained circular references.
To avoid such situations, I think that it should check for clone, _clone or another suitably named method on an object and if available, use the return value of that object as the clone instead of setting out to recursively clone the object itself.
I currently use a work-around where Ext.clone checks for obj.nodeType and obj.cloneNode on an object (for dom nodes) and is both exist, uses obj.cloneNode instead for cloning. So I add a dummy value to nodeType for my objects containing circular references and then add a method cloneNode which returns the object itself to overcome current behavior of infinite recursion by Ext.clone.--
Rahul Singla
-
18 Nov 2011 2:58 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
Test case I can use to create an official fix with?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Nov 2011 12:58 AM #3
Here's it:
And the error:Code:var a={}; var b={}; a.b=b; b.a=a; var c=Ext.clone(a);
RangeError: Maximum call stack size exceeded--
Rahul Singla


Reply With Quote