From 575f7f5670371da7113fd545a494b3c219bebb29 Mon Sep 17 00:00:00 2001 From: Anshul Jethvani Date: Fri, 6 Dec 2019 19:52:10 -0500 Subject: [PATCH] partially implemented SupportedPropertyNames --- components/script/dom/htmlformelement.rs | 28 ++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index b39bc1cf58a..0fafed06f40 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -363,7 +363,8 @@ impl HTMLFormElementMethods for HTMLFormElement { source: SourcedNameSource::Id, }; sourcedNamesVec.push(entry); - } else if child.has_attribute(&local_name!("name")) { + } + if child.has_attribute(&local_name!("name")) { let entry = SourcedName { name: child.get_string_attribute(&local_name!("name")), element: DomRoot::from_ref(&*child), @@ -384,7 +385,8 @@ impl HTMLFormElementMethods for HTMLFormElement { source: SourcedNameSource::Id, }; sourcedNamesVec.push(entry); - } else if child.has_attribute(&local_name!("name")) { + } + if child.has_attribute(&local_name!("name")) { let entry = SourcedName { name: child.get_string_attribute(&local_name!("name")), element: DomRoot::from_ref(&*child), @@ -395,6 +397,28 @@ impl HTMLFormElementMethods for HTMLFormElement { } } + // Step 4 + let past_names_map = self.past_names_map.borrow(); + for (key, val) in past_names_map.iter() { + let entry = SourcedName { + name: key.clone(), + element: DomRoot::from_ref(&*val.0), + source: SourcedNameSource::Past(now()-val.1), // calculate difference now()-val.1 to find age + }; + sourcedNamesVec.push(entry); + } + + // Step 5 + // TODO need to sort as per spec. This is a partially implemented function. + // Kindly guide us on how to refine this function further. + sourcedNamesVec.sort_by(|a, b| a.name.partial_cmp(&b.name).unwrap()); + + // 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 let mut namesVec: Vec = Vec::new(); for elem in sourcedNamesVec.iter() {