Permalink
Browse files

Item13373: fix issues with loader when using same brush multiple times

The previous loader called its callback immediately when another request
for the same brush was in progress, even if the request was not finished
yet. This would break all code blocks in the page.
  • Loading branch information...
1 parent 6be42c3 commit ba6a09fabf1bfa9490bd1b22bc22beaf99e9cb4a @jast jast committed Jul 30, 2015
Showing with 5 additions and 4 deletions.
  1. +5 −4 pub/System/DpSyntaxHighlighterPlugin/shInit.uncompressed.js
@@ -150,11 +150,12 @@
throw("no brush found for language '"+id+"'");
}
- if (brush.loaded) {
- callback();
+ if (brush.def) {
+ def.then(callback);
} else {
- brush.loaded = true;
- $.getScript(brush.url, callback);
+ brush.def = jQuery.Deferred();
+ brush.def.then(callback);
+ $.getScript(brush.url, function() { def.resolve(); });
}
}

0 comments on commit ba6a09f

Please sign in to comment.