Skip to content

Commit 04e34b4

Browse files
committed
Refactoring common function.
1 parent a154c67 commit 04e34b4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/highlightjs-line-numbers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@
7474

7575
duplicateMultilineNodes(element);
7676

77-
addLineNumbersBlockFor(element, firstLineIndex);
77+
element.innerHTML = addLineNumbersBlockFor(element.innerHTML, firstLineIndex);
7878
});
7979
}
8080

81-
function addLineNumbersBlockFor (element, firstLineIndex) {
81+
function addLineNumbersBlockFor (inputHtml, firstLineIndex) {
8282

83-
var lines = getLines(element.innerHTML);
83+
var lines = getLines(inputHtml);
8484

8585
if (lines.length > firstLineIndex) {
8686
var html = '';
@@ -106,8 +106,10 @@
106106
]);
107107
}
108108

109-
element.innerHTML = format('<table class="{0}">{1}</table>', [ TABLE_NAME, html ]);
109+
return format('<table class="{0}">{1}</table>', [ TABLE_NAME, html ]);
110110
}
111+
112+
return inputHtml;
111113
}
112114

113115
/**

0 commit comments

Comments
 (0)