Skip to content

Commit

Permalink
Fix syntax highlight initialization (go-gitea#7617)
Browse files Browse the repository at this point in the history
* Fix syntax highlight initialization

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

* semicolon
  • Loading branch information
silverwind committed Jul 26, 2019
1 parent 4c69e15 commit b9bd281
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 @@ -1974,7 +1974,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 b9bd281

Please sign in to comment.