File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ Themes:
29
29
30
30
- Added ` Rosé Pine ` theme [ William Wilkinson] [ ]
31
31
32
+ Improvements:
33
+
34
+ - Resolve the memory leak problem when creating multiple Highlight.js instances [ Imken] [ ]
35
+
32
36
CONTRIBUTORS
33
37
34
38
[ Josh Goebel ] : https://github.com/joshgoebel
@@ -39,6 +43,7 @@ CONTRIBUTORS
39
43
[ srawlins ] : https://github.com/srawlins
40
44
[ Alvin Joy ] : https://github.com/alvinsjoy
41
45
[ Aboobacker MK ] : https://github.com/tachyons
46
+ [ Imken ] : https://github.com/immccn123
42
47
43
48
44
49
## Version 11.10.0
Original file line number Diff line number Diff line change @@ -819,8 +819,17 @@ const HLJS = function(hljs) {
819
819
* auto-highlights all pre>code elements on the page
820
820
*/
821
821
function highlightAll ( ) {
822
+ function boot ( ) {
823
+ // if a highlight was requested before DOM was loaded, do now
824
+ highlightAll ( ) ;
825
+ }
826
+
822
827
// if we are called too early in the loading process
823
828
if ( document . readyState === "loading" ) {
829
+ // make sure the event listener is only added once
830
+ if ( ! wantsHighlight ) {
831
+ window . addEventListener ( 'DOMContentLoaded' , boot , false ) ;
832
+ }
824
833
wantsHighlight = true ;
825
834
return ;
826
835
}
@@ -829,16 +838,6 @@ const HLJS = function(hljs) {
829
838
blocks . forEach ( highlightElement ) ;
830
839
}
831
840
832
- function boot ( ) {
833
- // if a highlight was requested before DOM was loaded, do now
834
- if ( wantsHighlight ) highlightAll ( ) ;
835
- }
836
-
837
- // make sure we are in the browser environment
838
- if ( typeof window !== 'undefined' && window . addEventListener ) {
839
- window . addEventListener ( 'DOMContentLoaded' , boot , false ) ;
840
- }
841
-
842
841
/**
843
842
* Register a language grammar module
844
843
*
You can’t perform that action at this time.
0 commit comments