kiwix / libkiwix

Common code base for all Kiwix ports
https://download.kiwix.org/release/libkiwix/
GNU General Public License v3.0
112 stars 54 forks source link

Make library work with more browsers by polyfilling `replaceAll()` #1051

Closed Jaifroid closed 4 months ago

Jaifroid commented 4 months ago

In this file https://github.com/kiwix/libkiwix/blob/main/static/skin/viewer.js#L76, a replaceAll() method is used that is incompatible with a number of older browsers. We at Kiwix JS have found several cases where the fancy library cannot be used simply because of this method (e.g., any Chrome before 85, see https://caniuse.com/?search=replaceAll), even though the browser would otherwise support the library feature.

We tried to polyfill it ourselves, but due to CORS its' not possible for us to tamper with this script.

For more info see https://github.com/kiwix/kiwix-js/issues/1174 and https://github.com/kiwix/kiwix-js/pull/1190. And for a very small polyfill that could simply be added to the viewer.js without needing to download a package, see https://github.com/kiwix/kiwix-js/pull/1190/files.