maxZIndex becomes NULL when the last feature is removed, p=pvalsecc, r=me (closes #1670)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7712 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -128,9 +128,22 @@ OpenLayers.ElementsIndexer = OpenLayers.Class({
|
||||
|
||||
// Reset the maxium z-index based on the last item in the
|
||||
// order array.
|
||||
if (this.order.length > 0) {
|
||||
var lastId = this.order[this.order.length - 1];
|
||||
this.maxZIndex = this.indices[lastId];
|
||||
} else {
|
||||
this.maxZIndex = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clear
|
||||
*/
|
||||
clear: function() {
|
||||
this.order = [];
|
||||
this.indices = {};
|
||||
this.maxZIndex = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -395,6 +408,7 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
this.root.removeChild(this.root.firstChild);
|
||||
}
|
||||
}
|
||||
this.indexer.clear();
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -452,6 +452,82 @@
|
||||
OpenLayers.Util.getElement = OpenLayers.Util._getElement;
|
||||
}
|
||||
|
||||
function test_Elements_drawAndErase(t) {
|
||||
t.plan(20);
|
||||
|
||||
setUp();
|
||||
|
||||
var r = create_renderer();
|
||||
var element = document.createElement("div");
|
||||
r.root = element;
|
||||
document.body.appendChild(element);
|
||||
|
||||
r.createNode = function(type, id) {
|
||||
var element = document.createElement("div");
|
||||
element.id = id;
|
||||
return element;
|
||||
};
|
||||
r.setStyle = function(node, style, options, geometry) {
|
||||
return node;
|
||||
};
|
||||
|
||||
var geometry = {
|
||||
id: 'foo',
|
||||
CLASS_NAME: 'bar'
|
||||
};
|
||||
var style = {
|
||||
graphicZIndex: 10
|
||||
};
|
||||
var featureId = 'foo';
|
||||
r.drawGeometry(geometry, style, featureId);
|
||||
|
||||
function count(obj) {
|
||||
var result = 0;
|
||||
for (var i in obj) {
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
t.ok(r.root.childNodes.length == 1, "root is correctly filled");
|
||||
t.ok(r.indexer.maxZIndex == 10, "indexer.maxZIndex is correctly filled");
|
||||
t.ok(r.indexer.order.length == 1, "indexer.order is correctly filled");
|
||||
t.ok(count(r.indexer.indices) == 1, "indexer.indices is correctly filled");
|
||||
|
||||
r.eraseGeometry(geometry);
|
||||
|
||||
t.ok(r.root.childNodes.length == 0, "root is correctly cleared");
|
||||
t.ok(r.indexer.maxZIndex == 0, "indexer.maxZIndex is correctly reset");
|
||||
t.ok(r.indexer.order.length == 0, "indexer.order is correctly reset");
|
||||
t.ok(count(r.indexer.indices) == 0, "indexer.indices is correctly reset");
|
||||
|
||||
delete(style.graphicZIndex);
|
||||
r.drawGeometry(geometry, style, featureId);
|
||||
|
||||
t.ok(r.root.childNodes.length == 1, "root is correctly filled");
|
||||
t.ok(r.indexer.maxZIndex == 0, "indexer.maxZIndex is correctly filled");
|
||||
t.ok(r.indexer.order.length == 1, "indexer.order is correctly filled");
|
||||
t.ok(count(r.indexer.indices) == 1, "indexer.indices is correctly filled");
|
||||
|
||||
r.clear();
|
||||
|
||||
t.ok(r.root.childNodes.length == 0, "root is correctly cleared");
|
||||
t.ok(r.indexer.maxZIndex == 0, "indexer.maxZIndex is correctly reset");
|
||||
t.ok(r.indexer.order.length == 0, "indexer.order is correctly reset");
|
||||
t.ok(count(r.indexer.indices) == 0, "indexer.indices is correctly reset");
|
||||
|
||||
style.graphicZIndex = 12;
|
||||
r.drawGeometry(geometry, style, featureId);
|
||||
|
||||
t.ok(r.root.childNodes.length == 1, "root is correctly filled");
|
||||
t.ok(r.indexer.maxZIndex == 12, "indexer.maxZIndex is correctly filled");
|
||||
t.ok(r.indexer.order.length == 1, "indexer.order is correctly filled");
|
||||
t.ok(count(r.indexer.indices) == 1, "indexer.indices is correctly filled");
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user