Skip to content

Commit

Permalink
Line numbers: Fixed TypeError when lineNumberWrapper is null (#2337)
Browse files Browse the repository at this point in the history
If a code block doesn't contain code, line numbers will not be added but the resize event still expected them to be there resulting in a TypeError.
  • Loading branch information
lynette-li committed Apr 29, 2020
1 parent 053016e commit 4b61661
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugins/line-numbers/prism-line-numbers.js
Expand Up @@ -27,6 +27,9 @@
if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
var codeElement = element.querySelector('code');
var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
if (!codeElement || !lineNumbersWrapper) {
return;
}
var lineNumberSizer = element.querySelector('.line-numbers-sizer');
var codeLines = codeElement.textContent.split(NEW_LINE_EXP);

Expand Down
2 changes: 1 addition & 1 deletion plugins/line-numbers/prism-line-numbers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4b61661

Please sign in to comment.