aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlbuttonelement.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-05-23 11:48:09 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-05-23 15:12:19 +0530
commit102cdaa7cc8baedfd589b92a8c4baf73cc72d7d6 (patch)
tree55beacae701de096f640077c7f2df8ea885697af /components/script/dom/htmlbuttonelement.rs
parent6b039612bac3159a51d09e341c18f9a6ccc948b1 (diff)
downloadservo-102cdaa7cc8baedfd589b92a8c4baf73cc72d7d6.tar.gz
servo-102cdaa7cc8baedfd589b92a8c4baf73cc72d7d6.zip
Include <button type=submit> data whilst constructing the form dataset
Diffstat (limited to 'components/script/dom/htmlbuttonelement.rs')
-rw-r--r--components/script/dom/htmlbuttonelement.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs
index 82e88bdc355..43f0f925971 100644
--- a/components/script/dom/htmlbuttonelement.rs
+++ b/components/script/dom/htmlbuttonelement.rs
@@ -14,8 +14,9 @@ use dom::event::Event;
use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
use dom::htmlfieldsetelement::HTMLFieldSetElement;
-use dom::htmlformelement::{FormControl, FormSubmitter, ResetFrom};
-use dom::htmlformelement::{SubmittedFrom, HTMLFormElement};
+use dom::htmlformelement::HTMLFormElement;
+use dom::htmlformelement::{FormControl, FormDatum, FormDatumValue};
+use dom::htmlformelement::{FormSubmitter, ResetFrom, SubmittedFrom};
use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
use dom::nodelist::NodeList;
use dom::validation::Validatable;
@@ -137,6 +138,39 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
}
}
+impl HTMLButtonElement {
+ /// https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set
+ /// Steps range from 3.1 to 3.7 (specific to HTMLButtonElement)
+ pub fn form_datum(&self, submitter: Option<FormSubmitter>) -> Option<FormDatum> {
+ // Step 3.1: disabled state check is in get_unclean_dataset
+
+ // Step 3.1: only run steps if this is the submitter
+ if let Some(FormSubmitter::ButtonElement(submitter)) = submitter {
+ if submitter != self {
+ return None
+ }
+ } else {
+ return None
+ }
+ // Step 3.2
+ let ty = self.Type();
+ // Step 3.4
+ let name = self.Name();
+
+ if name.is_empty() {
+ // Step 3.1: Must have a name
+ return None;
+ }
+
+ // Step 3.9
+ Some(FormDatum {
+ ty: ty,
+ name: name,
+ value: FormDatumValue::String(self.Value())
+ })
+ }
+}
+
impl VirtualMethods for HTMLButtonElement {
fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)