mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Add comments for the "Constructing the form data set" algorithm
This commit is contained in:
parent
e4f86829d7
commit
8d2f9fc586
2 changed files with 22 additions and 10 deletions
|
@ -423,8 +423,12 @@ impl HTMLInputElement {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set
|
||||
/// Steps range from 3.1 to 3.7 which related to the HTMLInputElement
|
||||
pub fn get_form_datum(&self, submitter: Option<FormSubmitter>) -> Option<FormDatum> {
|
||||
// Step 3.2
|
||||
let ty = self.type_();
|
||||
// Step 3.4
|
||||
let name = self.Name();
|
||||
let is_submitter = match submitter {
|
||||
Some(FormSubmitter::InputElement(s)) => {
|
||||
|
@ -434,21 +438,22 @@ impl HTMLInputElement {
|
|||
};
|
||||
|
||||
match ty {
|
||||
// Step 3.1: it's a button but it is not submitter.
|
||||
atom!("submit") | atom!("button") | atom!("reset") if !is_submitter => return None,
|
||||
atom!("radio") | atom!("checkbox") => {
|
||||
if !self.Checked() || name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
// Step 3.1: it's the "Checkbox" or "Radio Button" and whose checkedness is false.
|
||||
atom!("radio") | atom!("checkbox") => if !self.Checked() || name.is_empty() {
|
||||
return None;
|
||||
},
|
||||
atom!("image") | atom!("file") => return None, // Unimplemented
|
||||
_ => {
|
||||
if name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
// Step 3.1: it's not the "Image Button" and doesn't have a name attribute.
|
||||
_ => if name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let mut value = self.Value();
|
||||
// Step 3.6
|
||||
if ty == atom!("radio") || ty == atom!("checkbox") {
|
||||
if value.is_empty() {
|
||||
value = DOMString::from("on");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue