fix: text area null regression

This commit is contained in:
dpiercey 2024-03-04 14:29:45 -07:00 committed by Dylan Piercey
parent bb250c9bd5
commit ccc19e2657
4 changed files with 9 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
"marko": patch
---
Fix regression where a textarea created with no value in the browser was setting `null` as the value.

View File

@ -116,7 +116,7 @@ function VElement(
this.___attributes = attrs || EMPTY_OBJECT;
this.___properties = props || EMPTY_OBJECT;
this.___nodeName = tagName;
this.___valueInternal = null;
this.___valueInternal = "";
this.___constId = constId;
this.___preserve = false;
this.___preserveBody = false;

View File

@ -50,8 +50,7 @@ VNode.prototype = {
if (this.___nodeName === "textarea") {
if (child.___Text) {
var childValue = child.___nodeValue;
this.___valueInternal = (this.___valueInternal || "") + childValue;
this.___valueInternal += child.___nodeValue;
} else {
throw TypeError();
}

View File

@ -696,10 +696,8 @@ function morphdom(fromNode, toNode, host, componentsContext) {
}
if (nodeName === "textarea") {
var newValue = toEl.___valueInternal || "";
var oldValue = vFromEl.___valueInternal || "";
if (oldValue !== newValue) {
fromEl.value = newValue;
if (toEl.___valueInternal !== vFromEl.___valueInternal) {
fromEl.value = toEl.___valueInternal;
}
} else {
morphChildren(fromEl, toEl, parentComponent);