Results 1 to 4 of 4

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 Premium User
    Join Date
    Mar 2009
    Posts
    243
    Vote Rating
    1
      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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,062
    Vote Rating
    1391
      0  

    Default

    Test case I can use to create an official fix with?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium User
    Join Date
    Mar 2009
    Posts
    243
    Vote Rating
    1
      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

  4. #4
    Sencha User
    Join Date
    Jul 2017
    Posts
    1
    Vote Rating
    0
      0  

    Default

    Did you find any solution to the Infinite Recursion issue while using Ext.Clone?


    Quote Originally Posted by r_honey View Post
    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
  •