Skip to content

Commit

Permalink
[merge addon] Use CSS :after to style scroll-lock icon
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
gorhill authored and marijnh committed Mar 17, 2018
1 parent df4cc22 commit 261d10b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions addon/merge/merge.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
color: #555;
line-height: 1;
}
.CodeMirror-merge-scrolllock:after {
content: "\21db\00a0\00a0\21da";
}
.CodeMirror-merge-scrolllock.CodeMirror-merge-scrolllock-enabled:after {
content: "\21db\21da";
}

.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion addon/merge/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
function setScrollLock(dv, val, action) {
dv.lockScroll = val;
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db  \u21da";
(val ? CodeMirror.addClass : CodeMirror.rmClass)(dv.lockButton, "CodeMirror-merge-scrolllock-enabled");
}

// Updating the marks for editor content
Expand Down

0 comments on commit 261d10b

Please sign in to comment.