2

I have a CSS problem in Safari. After changing the text of a html element the position of ::after does not update.

$('#view').text("Shorter text"); // does not update the position of the #view::after pseudo-element http://jsfiddle.net/cpdmLnw7/

But works perfectly in Chrome and Firefox.

Any ideas why?

Kārlis
  • 47
  • 6

1 Answers1

0

Seems to just be a bug in Safari. If you force a reflow it fixes itself.

E.g. based on a suggestion in https://stackoverflow.com/a/3485654/1469259:

    var span=$('#view');
    span.text("Changing text does not update").css("display","inline-block").height();
    span.css("display","inline");

The call to height() forces the browser to re-render the span after the style change (so that it can calculate the "new" height). Without it the updates are just rolled into one and nothing happens. You could achieve a similar effect using setTimeout(...) with a zero timeout.

Updated fiddle: http://jsfiddle.net/cpdmLnw7/4/

Community
  • 1
  • 1
CupawnTae
  • 14,192
  • 3
  • 29
  • 60