Fix loosing cursor position in Edge

See: https://github.com/patrick-steele-idem/morphdom/pull/100
This commit is contained in:
Patrick Steele-Idem 2017-03-22 10:10:16 -06:00
parent 292643de78
commit c40e07a4ca

View File

@ -42,14 +42,17 @@ module.exports = {
fromEl.value = newValue;
}
if (fromEl.firstChild) {
var firstChild = fromEl.firstChild;
if (firstChild) {
// Needed for IE. Apparently IE sets the placeholder as the
// node value and vise versa. This ignores an empty update.
if (!newValue && fromEl.firstChild.nodeValue == fromEl.placeholder) {
var oldValue = firstChild.nodeValue;
if (oldValue == newValue || (!newValue && oldValue == fromEl.placeholder)) {
return;
}
fromEl.firstChild.nodeValue = newValue;
firstChild.nodeValue = newValue;
}
},
SELECT: function(fromEl, toEl) {