"The Permalink control passes an element as the first parameter, however, the

initialize.apply is called with the arguments object, which causes an error if
an element is passed into the control." Also applied to Scale. Now fixed
with review from e-dog. (Closes #978) Fixes the only problem I found with 
migrating the Boston freemap to 2.5.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4333 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-09-16 15:59:11 +00:00
parent 294f84ba15
commit f505542fbe
4 changed files with 18 additions and 5 deletions

View File

@@ -31,9 +31,10 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
* Parameters: * Parameters:
* element - {DOMElement} * element - {DOMElement}
* base - {String} * base - {String}
* options - {Object} options to the control.
*/ */
initialize: function(element, base) { initialize: function(element, base, options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.element = OpenLayers.Util.getElement(element); this.element = OpenLayers.Util.getElement(element);
this.base = base || document.location.href; this.base = base || document.location.href;
}, },

View File

@@ -24,10 +24,10 @@ OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
* *
* Parameters: * Parameters:
* element - {DOMElement} * element - {DOMElement}
* base - {String} * options - {Object}
*/ */
initialize: function(element) { initialize: function(element, options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.element = OpenLayers.Util.getElement(element); this.element = OpenLayers.Util.getElement(element);
}, },

View File

@@ -19,6 +19,12 @@
map.events.triggerEvent("changelayer", {}); map.events.triggerEvent("changelayer", {});
t.ok(true, "permalink didn't bomb out."); t.ok(true, "permalink didn't bomb out.");
} }
function test_02_Control_Permalink_initwithelem (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(true, "If the above line doesn't throw an error, we're safe.");
}
function test_02_Control_Permalink_updateLinks (t) { function test_02_Control_Permalink_updateLinks (t) {
t.plan( 3 ); t.plan( 3 );

View File

@@ -10,6 +10,12 @@
t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" ); t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
t.eq( control.displayClass, "olControlScale", "displayClass is correct" ); t.eq( control.displayClass, "olControlScale", "displayClass is correct" );
} }
function test_02_Control_Scale_initwithelem (t) {
t.plan( 1 );
control = new OpenLayers.Control.Scale(OpenLayers.Util.getElement('scale'));
t.ok(true, "If this happens, then we passed. (FF throws an error above otherwise)");
}
function test_02_Control_Scale_updateScale (t) { function test_02_Control_Scale_updateScale (t) {
t.plan( 4 ); t.plan( 4 );