OpenLayers OpenLayers

Changeset 7829

Show
Ignore:
Timestamp:
08/22/08 09:23:16 (5 months ago)
Author:
euzuro
Message:

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)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control.js

    r7675 r7829  
    177177            this.events.on(this.eventListeners); 
    178178        } 
    179         this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 
     179        if (this.id == null) { 
     180            this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 
     181        } 
    180182    }, 
    181183 
  • trunk/openlayers/tests/Control.html

    r6719 r7829  
    44  <script type="text/javascript"> 
    55    function test_Control_constructor(t) { 
    6         t.plan(2); 
     6        t.plan(4); 
    77     
    88        var control = new OpenLayers.Control(); 
     
    1010        t.ok(control instanceof OpenLayers.Control, "new OpenLayers.Control returns object"); 
    1111        t.eq(control.displayClass, "olControl", "displayClass set correctly"); 
     12        t.ok(control.id != null, "default id assigned to control"); 
     13         
     14        var testID = {}; 
     15        control = new OpenLayers.Control({ 'id': testID }); 
     16        t.ok(control.id == testID, "if id specified in options, no default assigned."); 
    1217    } 
    1318