Skip to content

Commit 261d10b

Browse files
gorhillmarijnh
authored andcommitted
[merge addon] Use CSS :after to style scroll-lock icon
Primary motivation was to remove the use of `innerHTML` because the Firefox extension validator raises a warning about this. The obvious solution is to use `textContent` instead of `innerHTML` but I thought it could be useful to have the ability to pick a custom visual for the scroll-lock icon. As per MDN documentation, all the supported browsers as per CodeMirror documentation support `:after`.
1 parent df4cc22 commit 261d10b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

addon/merge/merge.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
color: #555;
4949
line-height: 1;
5050
}
51+
.CodeMirror-merge-scrolllock:after {
52+
content: "\21db\00a0\00a0\21da";
53+
}
54+
.CodeMirror-merge-scrolllock.CodeMirror-merge-scrolllock-enabled:after {
55+
content: "\21db\21da";
56+
}
5157

5258
.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
5359
position: absolute;

addon/merge/merge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
function setScrollLock(dv, val, action) {
212212
dv.lockScroll = val;
213213
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
214-
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db  \u21da";
214+
(val ? CodeMirror.addClass : CodeMirror.rmClass)(dv.lockButton, "CodeMirror-merge-scrolllock-enabled");
215215
}
216216

217217
// Updating the marks for editor content

0 commit comments

Comments
 (0)