Skip to content

Commit

Permalink
Fix syntax highlight initialization
Browse files Browse the repository at this point in the history
Previously hljs was initialized via a function that relies on the
DOMContentLoaded event, registerd after jQuery's 'ready' event. I assume
that with the recent jQuery update, DOMContentLoaded may not be
guaranteed to fire after 'ready'. Fixed this via vanilla JS initalization.

Fixes: go-gitea#7559
  • Loading branch information
silverwind committed Jul 25, 2019
1 parent 734aa96 commit 6998fc1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,10 @@ $(document).ready(function () {

// Highlight JS
if (typeof hljs != 'undefined') {
hljs.initHighlightingOnLoad();
const nodes = [].slice.call(document.querySelectorAll('pre code') || [])
for (let i = 0; i < nodes.length; i++) {
hljs.highlightBlock(nodes[i]);
}
}

// Dropzone
Expand Down

0 comments on commit 6998fc1

Please sign in to comment.