Skip to content

Commit

Permalink
Fix syntax highlight initialization (#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: #7559

* semicolon
  • Loading branch information
silverwind authored and zeripath committed Jul 25, 2019
1 parent 6782a70 commit 1d7dd7d
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 1d7dd7d

Please sign in to comment.