Skip to content

Commit 57403a8

Browse files
committed
avoid triggering error if hljs is not loaded (fixed php-debugbar#107)
1 parent d142729 commit 57403a8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/DebugBar/Resources/widgets.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,20 @@ if (typeof(PhpDebugBar) == 'undefined') {
4747
* @return {String}
4848
*/
4949
var highlight = PhpDebugBar.Widgets.highlight = function(code, lang) {
50-
if (typeof(code) == 'string') {
50+
if (typeof(code) === 'string') {
51+
if (!hljs) {
52+
return htmlize(code);
53+
}
5154
if (lang) {
5255
return hljs.highlight(lang, code).value;
5356
}
5457
return hljs.highlightAuto(code).value;
5558
}
5659

57-
code.each(function(i, e) { hljs.highlightBlock(e); });
60+
if (hljs) {
61+
code.each(function(i, e) { hljs.highlightBlock(e); });
62+
}
63+
return code;
5864
};
5965

6066
/**

0 commit comments

Comments
 (0)