Skip to content

Commit e355de6

Browse files
committed
Merge pull request #523 from wjt/faster-highlight-creation
Faster highlight creation
2 parents cb8d6c4 + 2b2700e commit e355de6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ui/highlighter.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ function highlightRange(normedRange, cssClass) {
2121
}
2222
var white = /^\s*$/;
2323

24-
var hl = $("<span class='" + cssClass + "'></span>");
25-
2624
// Ignore text nodes that contain only whitespace characters. This prevents
2725
// spans being injected between elements that can only contain a restricted
2826
// subset of nodes such as table rows and lists. This does mean that there
@@ -33,9 +31,11 @@ function highlightRange(normedRange, cssClass) {
3331
for (var i = 0, len = nodes.length; i < len; i++) {
3432
var node = nodes[i];
3533
if (!white.test(node.nodeValue)) {
36-
results.push(
37-
$(node).wrapAll(hl).parent().show()[0]
38-
);
34+
var hl = document.createElement('span');
35+
hl.className = cssClass;
36+
node.parentNode.replaceChild(hl, node);
37+
hl.appendChild(node);
38+
results.push(hl);
3939
}
4040
}
4141
return results;

0 commit comments

Comments
 (0)