Small patch to allow an 'id' property to be custom-set on controls -- without being overrided by the default random id generator. Thanks to Stephen I for the bug report. r=elemoine (Closes #1687)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7829 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -176,7 +176,9 @@ OpenLayers.Control = OpenLayers.Class({
|
|||||||
if(this.eventListeners instanceof Object) {
|
if(this.eventListeners instanceof Object) {
|
||||||
this.events.on(this.eventListeners);
|
this.events.on(this.eventListeners);
|
||||||
}
|
}
|
||||||
|
if (this.id == null) {
|
||||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,12 +3,17 @@
|
|||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function test_Control_constructor(t) {
|
function test_Control_constructor(t) {
|
||||||
t.plan(2);
|
t.plan(4);
|
||||||
|
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
|
|
||||||
t.ok(control instanceof OpenLayers.Control, "new OpenLayers.Control returns object");
|
t.ok(control instanceof OpenLayers.Control, "new OpenLayers.Control returns object");
|
||||||
t.eq(control.displayClass, "olControl", "displayClass set correctly");
|
t.eq(control.displayClass, "olControl", "displayClass set correctly");
|
||||||
|
t.ok(control.id != null, "default id assigned to control");
|
||||||
|
|
||||||
|
var testID = {};
|
||||||
|
control = new OpenLayers.Control({ 'id': testID });
|
||||||
|
t.ok(control.id == testID, "if id specified in options, no default assigned.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Control_addControl(t) {
|
function test_Control_addControl(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user