Negative spaces in Safari appear outside subscript that uses them
I expected mkern and mskip commands to only affect the spacing at a single place, but they seem to cause follow-on spacing bugs afterward.
An example can be seen by navigating to the katex.org homepage and typing the following into the demo box:
Y_{A} = 5 \\
Y_{\mskip{-4mu}A} = 5 \\
Y_{\mkern{-4mu}A} = 5
Results:

Notice that the spacing after the equals sign is different between lines, even though we would only have expected to change the space between Y and A.
Workaround: put negative mkern in the main symbol not the subscript.
{Y\mskip{-7mu}}_A=5
But it’s kind of annoying if you also want a superscript. Y_A^2 = 3 ends up turning into:
{Y\mskip{-7mu}}_A^{\mskip{9mu}2} = 3
Here is my updated workaround, seems to work (but is certainly not the right way to do things, and is probably brittle).
Y_{\mkern8mu{\mathllap{A}}} = 5 \\
Y_{\mkern8mu{\mathllap{A}}}^2 = 3
What browser are you using? I can't reproduce on Chrome on Windows 10, so I imagine it's browser-specific.

I also assume this has to do with the difficulty of negative spacing, so only applies to negative spacing. Can you confirm that positive spacing does not trigger this?
This is in Safari (v. 15.4 running on Mac OS 10.15.7). Only happens with negative spacing. (And the behavior is the same if negative spaces are added by \!.)
Seems like this doesn’t happen in either Firefox or Chrome. Mysterious. I wonder what causes the bug here.
For reference, here is Chrome 99 vs Safari 15.5, both on macOS 12.4:

The style rule .katex * {background: #f001} was added for these screenshots.
FWIW, this isn't new. I can reproduce on Safari versions 10, 11, 12, 13, 14, 15. But it's presumably a Safari bug, as it works fine in Chrome and Firefox.
I expect this is related to the makeVList table-row "hack" that implements vertical stacks as used in subscripts. #1409 discusses some alternatives but these are likely difficult. If any Safari or makeVList experts have any ideas, I'm all ears, but this seems like a pretty weird bug to work around...
I can't think of better workarounds than those you listed. You seem to need to pull the negative space outside any subscripts.