OpenLayers OpenLayers

Ticket #1041: collection.patch

File collection.patch, 1.3 kB (added by tschaub, 1 year ago)

fix collection.equals

  • lib/OpenLayers/Geometry/Collection.js

    old new  
    288288     */ 
    289289    equals: function(geometry) { 
    290290        var equivalent = true; 
    291         if(!geometry.CLASS_NAME || (this.CLASS_NAME != geometry.CLASS_NAME)) { 
     291        if(!geometry || !geometry.CLASS_NAME || 
     292           (this.CLASS_NAME != geometry.CLASS_NAME)) { 
    292293            equivalent = false; 
    293294        } else if(!(geometry.components instanceof Array) || 
    294295                  (geometry.components.length != this.components.length)) { 
  • tests/Geometry/test_Collection.html

    old new  
    132132        t.eq(coll.bounds.top, 70, "good top bounds"); 
    133133    } 
    134134     
     135    function test_Collection_equals(t) { 
     136        t.plan(1); 
     137        var geom = new OpenLayers.Geometry.Collection(); 
     138        t.ok(!geom.equals(), "collection.equals() returns false for undefined"); 
     139    } 
     140     
    135141    function test_07_Collection_addComponent(t)   { 
    136142        t.plan(10); 
    137143