Skip to content

Commit a25bcf7

Browse files
committed
Fixed plugin for IE
1 parent f0cff44 commit a25bcf7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/highlightjs-line-numbers.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
var parent = element.parentNode;
3131
var lines = parent.outerText.match(/\n/g);
3232

33-
lines = (lines ? lines.length : 0);// TODO: for IE + 1;
33+
lines = lines ? lines.length : 0;
34+
35+
// fix for IE
36+
if (isIE()) lines += 1;
37+
3438
if (lines > 1) {
3539
var l = '';
3640
for (var i = 0; i < lines; i++) {
@@ -45,4 +49,9 @@
4549
parent.insertBefore(linesPanel, element);
4650
}
4751
}
52+
53+
function isIE(userAgent) {
54+
userAgent = userAgent || w.navigator.userAgent;
55+
return userAgent.indexOf("MSIE ") > -1 || userAgent.indexOf("Trident/") > -1;
56+
}
4857
}(window));

0 commit comments

Comments
 (0)