Skip to content

Commit 0630b63

Browse files
committed
[placeholder addon] Further fix composition handling
Closes #6479
1 parent 5d2feac commit 0630b63

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

addon/display/placeholder.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@
5050

5151
function onComposition(cm) {
5252
setTimeout(function() {
53-
var empty = false, input = cm.getInputField()
54-
if (input.nodeName == "TEXTAREA")
55-
empty = !input.value
56-
else if (cm.lineCount() == 1)
57-
empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
53+
var empty = false
54+
if (cm.lineCount() == 1) {
55+
var input = cm.getInputField()
56+
empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length
57+
: !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
58+
}
5859
if (empty) setPlaceholder(cm)
5960
else clearPlaceholder(cm)
6061
}, 20)

0 commit comments

Comments
 (0)