Properly honor the manual flag in prism
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 1 Jul 2019 17:51:13 +0000 (19:51 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 1 Jul 2019 18:00:32 +0000 (20:00 +0200)
wcfsetup/install/files/js/3rdParty/prism/prism.js

index 18961e71808bc56a896fa0f02a302d8007bcdc3a..d4e81a35fb63769c6e9d69ac6394a9e9f660fe3f 100644 (file)
@@ -524,16 +524,24 @@ if (script) {
        _.filename = script.src;
 
        if (!_.manual && !script.hasAttribute('data-manual')) {
+               // WoltLab Start
+               _.highlightAutomaticallyCallback = function () {
+                       if (!_.manual) {
+                               _.highlightAll();
+                       }
+               }
+
                if(document.readyState !== "loading") {
                        if (window.requestAnimationFrame) {
-                               window.requestAnimationFrame(_.highlightAll);
+                               window.requestAnimationFrame(_.highlightAutomaticallyCallback);
                        } else {
-                               window.setTimeout(_.highlightAll, 16);
+                               window.setTimeout(_.highlightAutomaticallyCallback, 16);
                        }
                }
                else {
-                       document.addEventListener('DOMContentLoaded', _.highlightAll);
+                       document.addEventListener('DOMContentLoaded', _.highlightAutomaticallyCallback);
                }
+               // WoltLab End
        }
 }