From 1390a0a6f71c688d9d64d33fe4bae53886152003 Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 28 Sep 2007 21:37:05 +0000 Subject: [PATCH] Do not copy by reference size/bounds/position in making a new tile. All tests pass ie6/ff (Closes #1026). git-svn-id: http://svn.openlayers.org/trunk/openlayers@4579 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Tile.js | 6 +++--- tests/test_Tile.html | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index d4f3bc9027..4134aa77c8 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -93,10 +93,10 @@ OpenLayers.Tile = OpenLayers.Class({ */ initialize: function(layer, position, bounds, url, size) { this.layer = layer; - this.position = position; - this.bounds = bounds; + this.position = position.clone(); + this.bounds = bounds.clone(); this.url = url; - this.size = size; + this.size = size.clone(); //give the tile a unique id based on its BBOX. this.id = OpenLayers.Util.createUniqueID("Tile_"); diff --git a/tests/test_Tile.html b/tests/test_Tile.html index 821d92d5c5..094edcd6a7 100644 --- a/tests/test_Tile.html +++ b/tests/test_Tile.html @@ -5,7 +5,7 @@ var tile; function test_01_Tile_constructor (t) { - t.plan( 9 ); + t.plan( 12 ); var layer = {}; // bogus layer var position = new OpenLayers.Pixel(10,20); @@ -18,9 +18,12 @@ t.ok( tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object" ); t.eq( tile.layer, layer, "tile.layer set correctly"); t.ok( tile.position.equals(position), "tile.position set correctly"); + t.ok( tile.position != position, "tile.position set not by reference"); t.ok( tile.bounds.equals(bounds), "tile.bounds set correctly"); + t.ok( tile.bounds != bounds, "tile.bounds set not by reference"); t.eq( tile.url, url, "tile.url set correctly"); t.ok( tile.size.equals(size), "tile.size is set correctly" ); + t.ok( tile.size != size, "tile.size set not by reference"); t.ok( tile.id != null, "tile is given an id"); t.ok(OpenLayers.String.startsWith(tile.id, "Tile_"),