diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index 04fd17a6f8..39eb4fa10f 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -525,12 +525,19 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, { // place it. Note that this operation is O(log(n)). If there's a // performance problem (when dragging, for instance) this is // likely where it would be. - var insert = this.indexer ? this.indexer.insert(node) : null; - - if(insert) { - this.root.insertBefore(node, insert); + if (this.indexer) { + var insert = this.indexer.insert(node); + if (insert) { + this.root.insertBefore(node, insert); + } else { + this.root.appendChild(node); + } } else { - this.root.appendChild(node); + // if there's no indexer, simply append the node to root, + // but only if the node is a new one + if (node.parentNode !== this.root){ + this.root.appendChild(node); + } } this.postDraw(node);