From c59e66f1671af9ba4b8ddad52f80e52f5dfe6ac8 Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 19 May 2006 17:34:16 +0000 Subject: [PATCH] fixing bug introduced with [179]. basically, the Layer constructor should not be making new divs when it is initialized by a subclass. that was the point of [179]. the problem is that because of the way Layer.Grid is making the call to Layer's initialize() -- createing a new arguments array regardless of the orginal (ie although name is void, it nonetheless creates a new array with one element, a void element) well so then when init gets called it thinks it does have arguments. The real god's truth here is that we need a better way than if (arguments.length > 0) to distinguish between actual object creation and the creation of the classes. git-svn-id: http://svn.openlayers.org/trunk/openlayers@185 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer.js | 12 +++++++----- lib/OpenLayers/Layer/Grid.js | 6 +++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 325e8fa785..251ec53519 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -16,11 +16,13 @@ OpenLayers.Layer.prototype = { * @param {str} name */ initialize: function(name) { - this.name = name; - if (this.div == null) { - this.div = OpenLayers.Util.createDiv(); - this.div.style.width = "100%"; - this.div.style.height = "100%"; + if (arguments.length > 0) { + this.name = name; + if (this.div == null) { + this.div = OpenLayers.Util.createDiv(); + this.div.style.width = "100%"; + this.div.style.height = "100%"; + } } }, diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index fe7a179cd2..adfd522d99 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -22,7 +22,11 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), { * @param {hash} params */ initialize: function(name, url, params) { - OpenLayers.Layer.prototype.initialize.apply(this, [name]); + var newArguments = arguments; + if (arguments.length > 0) { + newArguments = [name]; + } + OpenLayers.Layer.prototype.initialize.apply(this, newArguments); this.url = url; this.params = params; },