fix: set default value for textarea when created (#1593)

(cherry picked from commit 1efae18402df3a236410794fc3d4f6a2076d1d64)
This commit is contained in:
Dylan Piercey 2020-08-10 08:58:39 -07:00
parent 36c501ce44
commit 00a0a5527d
No known key found for this signature in database
GPG Key ID: F6A9A2F45D062CBC
4 changed files with 24 additions and 2 deletions

View File

@ -180,7 +180,7 @@ VElement.prototype = {
}
if (tagName === "textarea") {
el.value = this.___value;
el.defaultValue = el.value = this.___value;
}
}

View File

@ -88,7 +88,9 @@ function morphdom(fromNode, toNode, doc, componentsContext) {
] = realNode;
}
morphChildren(realNode, vNode, parentComponent);
if (vNode.___nodeName !== "textarea") {
morphChildren(realNode, vNode, parentComponent);
}
}
onNodeAdded(realNode, componentsContext);

View File

@ -0,0 +1,6 @@
class {}
<input key="a" type="checkbox" value="abc" checked/>
<input key="b" type="checkbox" value="abc"/>
<input key="c" type="text" value="abc"/>
<textarea key="d">abc</textarea>

View File

@ -0,0 +1,14 @@
var expect = require("chai").expect;
module.exports = function(helpers) {
var component = helpers.mount(require.resolve("./index.marko"));
expect(component.getEl("a")).has.property("defaultValue", "abc");
expect(component.getEl("a")).has.property("defaultChecked", true);
expect(component.getEl("b")).has.property("defaultValue", "abc");
expect(component.getEl("b")).has.property("defaultChecked", false);
expect(component.getEl("c")).has.property("defaultValue", "abc");
expect(component.getEl("d")).has.property("defaultValue", "abc");
};