Ticket #1564: util.patch
| File util.patch, 6.6 kB (added by tschaub, 7 months ago) |
|---|
-
tests/Util.html
old new 169 169 170 170 function test_Util_applyDefaults(t) { 171 171 172 t.plan(1 0);172 t.plan(11); 173 173 174 174 var to = { 175 175 'a': "abra", … … 198 198 t.eq( ret["c"], "press", "key present in from and not ret successfully copied to ret"); 199 199 t.eq(to.toString(), "works", "correctly applies custom toString"); 200 200 t.eq(to.n, null, "correctly preserves null"); 201 202 var to; 203 var from = {rand: Math.random()}; 204 205 var ret = OpenLayers.Util.applyDefaults(to, from); 206 t.eq(ret.rand, from.rand, "works with undefined to"); 201 207 } 202 208 203 209 function test_Util_getParameterString(t) { … … 693 699 } 694 700 695 701 function tests_Util_extend(t) { 696 t.plan( 6);702 t.plan(7); 697 703 698 704 var source = { 699 705 num: Math.random(), … … 720 726 t.eq(destination.nada, "untouched", 721 727 "undefined source properties don't clobber existing properties"); 722 728 t.eq(window.property, undefined, "Property variable not clobbered."); 729 730 var destination; 731 var source = {rand: Math.random()}; 732 var ret = OpenLayers.Util.extend(destination, source); 733 t.eq(destination.rand, source.rand, "works with undefined destination"); 734 723 735 } 724 736 725 737 function test_XX_Util_Try(t) { -
lib/OpenLayers/Format/KML.js
old new 550 550 if (inlineStyleNode) { 551 551 var inlineStyle= this.parseStyle(inlineStyleNode); 552 552 if (inlineStyle) { 553 feature.style = OpenLayers.Util.extend( {},554 feature.style);555 OpenLayers.Util.extend(feature.style, inlineStyle);553 feature.style = OpenLayers.Util.extend( 554 feature.style, inlineStyle 555 ); 556 556 } 557 557 } 558 558 -
lib/OpenLayers/Map.js
old new 1335 1335 * false. 1336 1336 */ 1337 1337 pan: function(dx, dy, options) { 1338 // this should be pushed to applyDefaults and extend 1339 if (!options) { 1340 options = {}; 1341 } 1342 OpenLayers.Util.applyDefaults(options, { 1338 options = OpenLayers.Util.applyDefaults(options, { 1343 1339 animate: true, 1344 1340 dragging: false 1345 1341 }); -
lib/OpenLayers/Util.js
old new 49 49 * {Object} The destination object. 50 50 */ 51 51 OpenLayers.Util.extend = function(destination, source) { 52 if(destination && source) { 52 destination = destination || {}; 53 if(source) { 53 54 for(var property in source) { 54 55 var value = source[property]; 55 56 if(value !== undefined) { … … 521 522 * in place and returned by this function. 522 523 */ 523 524 OpenLayers.Util.applyDefaults = function (to, from) { 524 525 to = to || {}; 525 526 /* 526 527 * FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative 527 528 * prototype object" when calling hawOwnProperty if the source object is an -
lib/OpenLayers/Layer/MapServer.js
old new 42 42 newArguments.push(name, url, params, options); 43 43 OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); 44 44 45 if (arguments.length > 0) { 46 OpenLayers.Util.applyDefaults( 47 this.params, 48 this.DEFAULT_PARAMS 49 ); 50 } 45 this.params = OpenLayers.Util.applyDefaults( 46 this.params, this.DEFAULT_PARAMS 47 ); 51 48 52 49 // unless explicitly set in options, if the layer is transparent, 53 50 // it will be an overlay -
lib/OpenLayers/Layer/WorldWind.js
old new 54 54 var newArguments = []; 55 55 newArguments.push(name, url, params, options); 56 56 OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); 57 this.params = (params ? params : {}); 58 if (params) { 59 OpenLayers.Util.applyDefaults( 60 this.params, 61 this.DEFAULT_PARAMS 62 ); 63 } 57 this.params = OpenLayers.Util.applyDefaults( 58 this.params, this.DEFAULT_PARAMS 59 ); 64 60 }, 65 61 /** 66 62 * Method: addTile -
lib/OpenLayers/Layer/KaMap.js
old new 64 64 var newArguments = []; 65 65 newArguments.push(name, url, params, options); 66 66 OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); 67 this.params = (params ? params : {}); 68 if (params) { 69 OpenLayers.Util.applyDefaults( 70 this.params, 71 this.DEFAULT_PARAMS 72 ); 73 } 67 this.params = OpenLayers.Util.applyDefaults( 68 this.params, this.DEFAULT_PARAMS 69 ); 74 70 }, 75 71 76 72 /** -
lib/OpenLayers/Layer/WFS.js
old new 138 138 this.options.geometry_column = "the_geom"; 139 139 } 140 140 141 this.params = params; 142 OpenLayers.Util.applyDefaults( 143 this.params, 144 OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) 145 ); 141 this.params = OpenLayers.Util.applyDefaults( 142 params, 143 OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) 144 ); 146 145 this.url = url; 147 146 }, 148 147
