Not my comment. This fix was copied directly from the WMF codebase. Do you want me to work on a better fix that we can pass on to the foundation for them to implement as well?