From 51b31bc0a06f684ef86c2abd7857e678285eb5ca Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 12 Jul 2007 16:36:36 +0000 Subject: [PATCH] #832 - changing the name of the second arg for the Feature.Vector constructor, mainly for documentation sake - note that this is not an api change - Feature.Vector inherits from Feature - Feature exposes a data property, Feature.Vector exposes an attributes property, both point to the same thing for Feature.Vector - this change does not alter that redundancy, only changes the argument names for the constructor - and adds tests - I'll leave the data/attributes property discussion for later git-svn-id: http://svn.openlayers.org/trunk/openlayers@3717 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Feature/Vector.js | 13 ++++++++----- tests/Feature/test_Vector.html | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index a7576a8410..920c922e72 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -66,17 +66,20 @@ OpenLayers.Feature.Vector.prototype = * Parameters: * geometry - {} The geometry that this feature * represents. - * data - {Object} An optional object that will be mapped to . + * attributes - {Object} An optional object that will be mapped to the + * property. * style - {Object} An optional style object. */ - initialize: function(geometry, data, style) { - OpenLayers.Feature.prototype.initialize.apply(this, [null, null, data]); + initialize: function(geometry, attributes, style) { + OpenLayers.Feature.prototype.initialize.apply(this, + [null, null, attributes]); this.lonlat = null; this.geometry = geometry; this.state = null; this.attributes = new Object(); - if (data) { - this.attributes = OpenLayers.Util.extend(this.attributes, data); + if (attributes) { + this.attributes = OpenLayers.Util.extend(this.attributes, + attributes); } this.style = style ? style : null; }, diff --git a/tests/Feature/test_Vector.html b/tests/Feature/test_Vector.html index 52e83e22ce..681a459c6f 100644 --- a/tests/Feature/test_Vector.html +++ b/tests/Feature/test_Vector.html @@ -5,12 +5,22 @@ var map; var feature; - function test_01_Feature_Vector_constructor (t) { - t.plan( 1 ); + function test_Feature_Vector_constructor(t) { + t.plan(3); + + var geometry = new OpenLayers.Geometry(); + geometry.id = Math.random(); + var style = {foo: "bar"}; + var attributes = {bar: "foo"}; - feature = new OpenLayers.Feature.Vector(); + feature = new OpenLayers.Feature.Vector(geometry, attributes, style); - t.ok( feature instanceof OpenLayers.Feature.Vector, "new OpenLayers.Feature.Vector returns Feature.Vector object" ); + t.ok(feature instanceof OpenLayers.Feature.Vector, + "new OpenLayers.Feature.Vector returns Feature.Vector object" ); + t.eq(feature.attributes, attributes, + "attributes property set properly" ); + t.eq(feature.geometry.id, geometry.id, + "geometry.property set properly" ); }