Changeset 5162


Ignore:
Timestamp:
Nov 9, 2007 12:13:31 PM (9 years ago)
Author:
elemoine
Message:

Make OpenLayers.Util.applyDefaults() return the modified object. To be consistent with OpenLayers.Util.Extend() and be able to use anonymous object as the 'to' object. Thanks fredj for the patch and tests. Thanks euzuro and crschmidt for the reviews. (closes #992)

Location:
trunk/openlayers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openlayers/lib/OpenLayers/Util.js

    r5101 r5162  
    504504        }
    505505    }
     506    return to;
    506507};
    507508
  • trunk/openlayers/tests/test_Util.html

    r4783 r5162  
    144144    function test_06_Util_applyDefaults(t) {
    145145   
    146         t.plan(4);
     146        t.plan(8);
    147147       
    148148        var to = {
     
    162162        t.eq( to["b"], "blorg", "key present in to and from, maintained in to");
    163163        t.eq( to["c"], "press", "key present in from and not to successfully copied to to");
     164
     165        var ret = OpenLayers.Util.applyDefaults({'a': "abra",'b': "blorg"}, from);
     166        t.ok( ret instanceof Object, " applyDefaults returns an object");
     167        t.eq( ret["a"], "abra", "key present in ret but not from maintained");
     168        t.eq( ret["b"], "blorg", "key present in ret and from, maintained in ret");
     169        t.eq( ret["c"], "press", "key present in from and not ret successfully copied to ret");
    164170    }
    165171
Note: See TracChangeset for help on using the changeset viewer.