Results 1 to 3 of 3

Thread: Ext.clone should check for a custom clone(), _clone() or another suitable method

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    240
    Vote Rating
    0
      0  

    Default 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.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Vote Rating
    1297
      0  

    Default

    Test case I can use to create an official fix with?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Posts
    240
    Vote Rating
    0
      1  

    Default

    Here's it:

    Code:
    var a={};
    var b={};
    a.b=b;
    b.a=a;
    var c=Ext.clone(a);
    And the error:
    RangeError: Maximum call stack size exceeded

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •