Skip to content

Commit 96cd888

Browse files
adrianheinemarijnh
authored andcommitted
Convert a few long CSS strings to template strings
1 parent cef4089 commit 96cd888

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/display/scrolling.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export function maybeScrollWindow(cm, coords) {
1717
if (coords.top + box.top < 0) doScroll = true
1818
else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false
1919
if (doScroll != null && !phantom) {
20-
let scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
21-
(coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
22-
(coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
23-
coords.left + "px; width: 2px;")
20+
let scrollNode = elt("div", "\u200b", null, `position: absolute;
21+
top: ${coords.top - display.viewOffset - paddingTop(cm.display)}px;
22+
height: ${coords.bottom - coords.top + scrollGap(cm) + display.barHeight}px;
23+
left: ${coords.left}px; width: 2px;`)
2424
cm.display.lineSpace.appendChild(scrollNode)
2525
scrollNode.scrollIntoView(doScroll)
2626
cm.display.lineSpace.removeChild(scrollNode)

src/display/selection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ function drawSelectionRange(cm, range, output) {
5757
if (top < 0) top = 0
5858
top = Math.round(top)
5959
bottom = Math.round(bottom)
60-
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
61-
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
62-
"px; height: " + (bottom - top) + "px"))
60+
fragment.appendChild(elt("div", null, "CodeMirror-selected", `position: absolute; left: ${left}px;
61+
top: ${top}px; width: ${width == null ? rightSide - left : width}px;
62+
height: ${bottom - top}px`))
6363
}
6464

6565
function drawForLine(line, fromArg, toArg) {

src/input/TextareaInput.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ TextareaInput.prototype = copyObj({
284284
let oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
285285
input.wrapper.style.cssText = "position: absolute"
286286
let wrapperBox = input.wrapper.getBoundingClientRect()
287-
te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
288-
"px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
289-
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
290-
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"
287+
te.style.cssText = `position: absolute; width: 30px; height: 30px;
288+
top: ${e.clientY - wrapperBox.top - 5}px; left: ${e.clientX - wrapperBox.left - 5}px;
289+
z-index: 1000; background: ${ie ? "rgba(255, 255, 255, .05)" : "transparent"};
290+
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`
291291
let oldScrollY
292292
if (webkit) oldScrollY = window.scrollY // Work around Chrome issue (#2712)
293293
display.input.focus()

src/measurement/update_line.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ function updateLineGutter(cm, lineView, lineN, dims) {
9595
if (lineView.line.gutterClass) {
9696
let wrap = ensureLineWrapped(lineView)
9797
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
98-
"left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
99-
"px; width: " + dims.gutterTotalWidth + "px")
98+
`left: ${cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth}px
99+
width: ${dims.gutterTotalWidth}px`)
100100
wrap.insertBefore(lineView.gutterBackground, lineView.text)
101101
}
102102
let markers = lineView.line.gutterMarkers
103103
if (cm.options.lineNumbers || markers) {
104104
let wrap = ensureLineWrapped(lineView)
105-
let gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
106-
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px")
105+
let gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", `left:
106+
${cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth}px`)
107107
cm.display.input.setUneditable(gutterWrap)
108108
wrap.insertBefore(gutterWrap, lineView.text)
109109
if (lineView.line.gutterClass)
@@ -112,13 +112,13 @@ function updateLineGutter(cm, lineView, lineN, dims) {
112112
lineView.lineNumber = gutterWrap.appendChild(
113113
elt("div", lineNumberFor(cm.options, lineN),
114114
"CodeMirror-linenumber CodeMirror-gutter-elt",
115-
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
116-
+ cm.display.lineNumInnerWidth + "px"))
115+
`left: ${dims.gutterLeft["CodeMirror-linenumbers"]}px;
116+
width: ${cm.display.lineNumInnerWidth}px`))
117117
if (markers) for (let k = 0; k < cm.options.gutters.length; ++k) {
118118
let id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]
119119
if (found)
120-
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
121-
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"))
120+
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
121+
`left: ${dims.gutterLeft[id]}px; width: ${dims.gutterWidth[id]}px`))
122122
}
123123
}
124124
}

0 commit comments

Comments
 (0)