Skip to content

Commit 970a4d3

Browse files
committed
(fix) fire after:highlightElement after DOM is updated
1 parent 947e925 commit 970a4d3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

VERSION_11_UPGRADE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ hljs.registerAliases(["php3","php4","php5","php6","php7","php8"],{ languageName:
7070

7171
### Behavioral changes
7272

73+
- `after:highlightElement` plugin callback is now fired *after* the DOM has been updated, not before.
74+
7375
#### API changes
7476

7577
- The option `ignoreIllegals` is now `true` by default (for `highlight()`). Previously it was `false`.

src/highlight.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,6 @@ const HLJS = function(hljs) {
738738
const text = node.textContent;
739739
const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text);
740740

741-
fire("after:highlightElement", { el: element, result, text });
742-
743741
element.innerHTML = result.value;
744742
updateClassName(element, language, result.language);
745743
element.result = {
@@ -754,6 +752,8 @@ const HLJS = function(hljs) {
754752
relevance: result.secondBest.relevance
755753
};
756754
}
755+
756+
fire("after:highlightElement", { el: element, result, text });
757757
}
758758

759759
/**

0 commit comments

Comments
 (0)