Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    27
    Vote Rating
    0
    extbio is on a distinguished road

      0  

    Default [CLOSED-900] Ext.apply Wrong Behavior

    [CLOSED-900] Ext.apply Wrong Behavior


    Ext version tested:
    • Ext 3.1.0 (but I believe it's the same for Ext 2.x or more)


    Description:
    • Ext.apply(o,c,d) values in defaults d should NOT overwrite existing values in o, but instead everything in d will overwrite o. This creates multiple potential issues.


    Test Case:

    Code:
    var o = {a:1,c:3}, c = {a:3}, d = {c:5};
    Ext.apply(o, c, d);
    for(i in o) alert(i + ':' + o[i]);
    Steps to reproduce the problem:
    • Run the code above


    The result that was expected:
    • "a:3", "c:3"


    The result that occurs instead:
    • "a:3", "c:5"


    Debugging already done:
    • Yes, it's code in Ext.apply
      Code:
          if(defaults){
              Ext.apply(o, defaults);
          }


    Possible fix:

    • Code:
          if(o && typeof defaults == 'object'){
              for(var p in defaults){
                  if(o[p] == null) o[p] = defaults[p];
              }
          }

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    18
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    The documentation needs to made more clear, but at this point I cannot see changing the behavior as it could have a serious impact on existing applications.

  3. #3
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    27
    Vote Rating
    0
    extbio is on a distinguished road

      0  

    Default


    Yeah, I agree. The "defaults" in documentation was misleading and does not match the code. The code's actually more like config1 and config2. If the documentation is fixed to indicate this behavior, it would not be an issue for programmers.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    I've updated the docs to add extra info about this.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 2

Tags for this Thread