diff options
author | Anshul Jethvani <ajethva@ncsu.edu> | 2019-12-16 01:41:59 -0500 |
---|---|---|
committer | Anshul Jethvani <ajethva@ncsu.edu> | 2019-12-16 01:41:59 -0500 |
commit | 254bbc3b8c028ab49bc9b109ca3c683c9fceb907 (patch) | |
tree | cff81c1a2397aa5a1507583a0b2e4475f8a7f132 /components/script/dom/htmlformelement.rs | |
parent | 4682d9231d9cb96b2febdd38b83dde14f824849e (diff) | |
download | servo-254bbc3b8c028ab49bc9b109ca3c683c9fceb907.tar.gz servo-254bbc3b8c028ab49bc9b109ca3c683c9fceb907.zip |
removed duplicate entries from sourcedNamesVec for step 7 of SupportedPropertyNames
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rw-r--r-- | components/script/dom/htmlformelement.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 57dd48ba065..879d0a7c275 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -274,7 +274,8 @@ impl HTMLFormElementMethods for HTMLFormElement { .downcast::<HTMLElement>() .map_or(false, |c| c.is_listed_element()) { - if child.has_attribute(&local_name!("id")) || + if (child.has_attribute(&local_name!("id")) && + child.get_string_attribute(&local_name!("id")) == name) || (child.has_attribute(&local_name!("name")) && child.get_string_attribute(&local_name!("name")) == name) { @@ -286,7 +287,8 @@ impl HTMLFormElementMethods for HTMLFormElement { if candidates.len() == 0 { for child in controls.iter() { if child.is::<HTMLImageElement>() { - if child.has_attribute(&local_name!("id")) || + if (child.has_attribute(&local_name!("id")) && + child.get_string_attribute(&local_name!("id")) == name) || (child.has_attribute(&local_name!("name")) && child.get_string_attribute(&local_name!("name")) == name) { @@ -459,13 +461,16 @@ impl HTMLFormElementMethods for HTMLFormElement { // Step 6 sourcedNamesVec.retain(|sn| !sn.name.to_string().is_empty()); - // Step 7 - // Q1. Unable to clearly understand. It seems to contradict with step 4. - - // Step 8 + // Step 7-8 let mut namesVec: Vec<DOMString> = Vec::new(); for elem in sourcedNamesVec.iter() { - namesVec.push(elem.name.clone()); + if namesVec + .iter() + .find(|name| name.to_string() == elem.name.to_string()) + .is_none() + { + namesVec.push(elem.name.clone()); + } } return namesVec; |