renderGFM method called twice on page load (in issue page)
I've found that on an issue page like this one, the renderGFM
gets invoked for the issue description contents twice.
To reproduce:
In render_gfm.js
, add console.log
:
$.fn.renderGFM = function renderGFM() {
console.log('rendering GFM!');
// ...
};
When you go to a project issue, you'll see rendering GFM!
twice in the console.
This appears to be due to an explicit call to renderGFM
from the issue description Vue component, and a global catch-all $(() => $('body').renderGFM());
statement within render_gfm.js
.
This causes cases like renderMath
to be run multiple times targeting the same elements because it is an asynchronous method and there is no guarantee that it will be complete before renderGFM
is called a second time.
We should make methods like renderMath
and renderMermaid
return Promise objects, and we should queue all calls to renderGFM
such that subsequent calls will not run until the previous one has completed.