Update SVG output so that following a link scrolls to the top of the tag. (mathjax/MathJax#2588) #670
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.
In Firefox, following a link in SVG output would scroll to the bottom of the linked content rather than the top. In Safari, that would occur if the linked content was a
<text>
node, like from a\tag
withmtextInheritFont: true
. This PR adjusts the output of elements with ID so that Firefox and Safari (and Chrome) all scroll to the top of the linked content.That required shifting the element with the ID upward by its height, and then shifting its contents down by the sea amount (so that it is in the correct visual location, but the element's location for linking purposes is the top of the content. A
<text>
element is also added so that Safari will scroll to the right location.Since this required putting some unexpected elements as the children of the node with the
id
attribute, a newfirstChild()
method was added that skips over the unexpected nodes. That also allows moving therect
that was used as the hotbox for anhref
to also be put inside the element with thehref
rather than just before it, as in the past. (This corresponds to Peter's suggestion in mathjax/MathJax#2530.) ThefirstChild()
method skips thehref
element as well.Resolves mathjax/MathJax#2588.