Leaflet popup with dynamic content not centered over marker
It looks like leaflet is determining the width of the infobox when it renders it. You're adding text after it's been displayed so leaflet no longer knows its actual size, and thus cannot center it properly.
Try the setPopupContent()
method from the documentation in this slightly long-winded example:
m = L.marker([51.5, -0.09]).addTo(map);
m.bindPopup("<b>Hello world!</b><br />I am a popup<span></span>", {maxWidth: "none"})
m.openPopup();
var a = m.getPopup();
var b = a._content.replace("<span></span>","<span>asdasdasda</span>");
m.setPopupContent(b);
JSFIDDLE