I was occasionally seeing weird baseline calculations in firefox that would then position the text wrongly #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After a lot of debugging it seemed to come down to a strange situation in Firefox where the img.offsetTop property wouldn't be accurate immediately after it was appended to the dom, but would be updated if given a chance. Might have been some sort of threading issue? If you stepped through everything it worked fine, but running over the code and breaking on the next line produced this weirdness:
I tried replacing the inserted img tag with a span to see if that would solve the problem and it seemed to. I also use font-size: 0px instead of img.height = 1, which should result in a 1px more accurate baseline reading.