Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements basic form resetting #4133

Merged
merged 12 commits into from Dec 16, 2014

htmltextarea: Fixed some value_changed issues

Also modified tests/html/textarea.html to allow for the testing of the
textarea's dirty value flag.
  • Loading branch information
mttr committed Dec 16, 2014
commit a5c0bb708d03b1e878f419617fb016853d2200bb
@@ -148,7 +148,7 @@ impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {
// if the element's dirty value flag is false, then the element's
// raw value must be set to the value of the element's textContent IDL attribute
if !self.value_changed.get() {
self.SetValue(node.GetTextContent().unwrap());
self.reset();
}
}

@@ -159,7 +159,9 @@ impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {

// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-value
fn SetValue(self, value: DOMString) {
// TODO move the cursor to the end of the field
self.textinput.borrow_mut().set_content(value);
self.value_changed.set(true);
self.force_relayout();
}
}
@@ -255,7 +257,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
_ => (),
}

if child.is_text() {
if child.is_text() && !self.value_changed.get() {
self.reset();
}
}
@@ -1,6 +1,25 @@
<html>
<head></head>
<body>
<textarea name="textarea">Write something here
<form>
<textarea id="textarea">Write something here
and maybe here</textarea>
<button id=setcontent type=button>setContent</button>
<button id=setvalue type=button>setValue</button>
<input type=reset>
<script>
var text_area = document.getElementById("textarea");
var set_c = document.getElementById("setcontent");
var value = document.getElementById("setvalue");
var x = 0;

set_c.addEventListener("click", function () {
text_area.textContent = x;
x++;
});

value.addEventListener("click", function () {
text_area.value = "new value!";
});
</script>
</body>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.