diff --git a/layout/_third-party/math/mathjax.swig b/layout/_third-party/math/mathjax.swig
index 1a7b3df136..1b12c88d7a 100644
--- a/layout/_third-party/math/mathjax.swig
+++ b/layout/_third-party/math/mathjax.swig
@@ -33,15 +33,19 @@
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i += 1) {
- all[i].SourceElement().parentNode.className += ' has-jax';
+ document.getElementById(all[i].inputID + '-Frame').parentNode.className += ' has-jax';
}
});