[OpenLayers-Commits] r2365 - in sandbox/vector-2.4: lib/OpenLayers tests
commits at openlayers.org
commits at openlayers.org
Mon Mar 5 20:25:59 EST 2007
Author: euzuro
Date: 2007-03-05 20:25:56 -0500 (Mon, 05 Mar 2007)
New Revision: 2365
Modified:
sandbox/vector-2.4/lib/OpenLayers/Geometry.js
sandbox/vector-2.4/tests/test_Geometry.html
Log:
give OpenLayers.Geometry a good destroy() method and test
Modified: sandbox/vector-2.4/lib/OpenLayers/Geometry.js
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-06 01:23:44 UTC (rev 2364)
+++ sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-06 01:25:56 UTC (rev 2365)
@@ -36,6 +36,27 @@
},
/**
+ *
+ */
+ destroy: function() {
+ this.id = null;
+
+ //TBD: style? what is this?
+ if (this.style) {
+ this.style.destroy();
+ }
+ this.style = null;
+
+ this.bounds = null;
+ this.feature = null;
+
+ if (this.events) {
+ this.events.destroy();
+ }
+ this.events = null;
+ },
+
+ /**
* Set the bounds for this Geometry.
*
* @param {OpenLayers.LonLat|OpenLayers.Geometry.Point|OpenLayers.Bounds} object
Modified: sandbox/vector-2.4/tests/test_Geometry.html
===================================================================
--- sandbox/vector-2.4/tests/test_Geometry.html 2007-03-06 01:23:44 UTC (rev 2364)
+++ sandbox/vector-2.4/tests/test_Geometry.html 2007-03-06 01:25:56 UTC (rev 2365)
@@ -193,9 +193,40 @@
*
******/
+ function test_99_Geometry_destroy(t) {
+ t.plan( 7 );
+ var g = new OpenLayers.Geometry();
+ g.style = {
+ 'destroy': function() {
+ g_style_destroy = {};
+ }
+ };
+ g.bounds = new OpenLayers.Bounds();
+ g.feature = new Object();
+ g.events = {
+ 'destroy': function() {
+ g_events_destroy = {};
+ }
+ };
+ g_style_destroy = null;
+ g_events_destroy = {};
+ g.destroy();
+
+ t.eq(g.id, null, "id nullified");
+ t.ok(g_style_destroy != null, "style.destroy() called on non-null style");
+ t.eq(g.style, null, "style nullified");
+
+ t.eq(g.bounds, null, "bounds nullified");
+ t.eq(g.feature, null, "feature reference nullified");
+
+ t.ok(g_events_destroy != null, "events.destroy() called on non-null events");
+ t.eq(g.events, null, "events nullified");
+ }
+
+
// -->
</script>
</head>
More information about the Commits
mailing list