Skip to content

Commit

Permalink
removed duplicate entries from sourcedNamesVec for step 7 of Supporte…
Browse files Browse the repository at this point in the history
…dPropertyNames
  • Loading branch information
amj23897 committed Dec 16, 2019
1 parent 4682d92 commit 254bbc3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions components/script/dom/htmlformelement.rs
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 254bbc3

Please sign in to comment.