diff --git a/lib/OpenLayers/Renderer/SVG.js b/lib/OpenLayers/Renderer/SVG.js index f3630f8c47..640447ebbf 100644 --- a/lib/OpenLayers/Renderer/SVG.js +++ b/lib/OpenLayers/Renderer/SVG.js @@ -291,23 +291,28 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { var href = "#" + id; pos = this.getPosition(node); widthFactor = this.symbolSize[id] / size; - // Only set the href if it is different from the current one. - // This is a workaround for strange rendering behavior in FF3. - if (node.getAttributeNS(this.xlinkns, "href") != href) { - node.setAttributeNS(this.xlinkns, "href", href); - } else if (size != parseFloat(node.getAttributeNS(null, "width"))) { - // hide the element (and force a reflow so it really gets - // hidden. This workaround is needed for Safari. - node.style.visibility = "hidden"; - this.container.scrollLeft = this.container.scrollLeft; + + // remove the node from the dom before we modify it. This + // prevents various rendering issues in Safari and FF + var parent = node.parentNode; + var nextSibling = node.nextSibling; + if(parent) { + parent.removeChild(node); } + + node.setAttributeNS(this.xlinkns, "href", href); node.setAttributeNS(null, "width", size); node.setAttributeNS(null, "height", size); node.setAttributeNS(null, "x", pos.x - offset); node.setAttributeNS(null, "y", pos.y - offset); - // set the visibility back to normal (after the Safari - // workaround above) - node.style.visibility = ""; + + // now that the node has all its new properties, insert it + // back into the dom where it was + if(nextSibling) { + parent.insertBefore(node, nextSibling); + } else if(parent) { + parent.appendChild(node); + } } else { node.setAttributeNS(null, "r", style.pointRadius); }