The fix we did in XWIKI-20183 is not perfect. We restore the original Array.from using a setTimeout(() => {}, 0) hoping that our callback is called after the Prototpye.js code is loaded (and Array.from is overridden). This happens most of the time in practice because Prototype.js is cached. But it is possible that our callback is called to early, when Prototype.js is not cached and / or the network is slow. I can reproduce this consistently using Chrome with cache disabled and setting throttling to "Slow 4G" or even "Fast 4G". This issue causes for instance the MathJax macro to fail. I used this content to reproduce:
The failure is in tex-chtml.js at this line:
where this._fallback is an iterable object, as per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol . Prototype's implementation of Array.from is too old to support iterable objects. As a result the MathJax macro shows "Math input error", and the JavaScript exception is:
because Prototype's Array.from returns an empty array when given an iterable object. |