Skip to content

Commit

Permalink
partially implemented SupportedPropertyNames
Browse files Browse the repository at this point in the history
  • Loading branch information
amj23897 committed Dec 7, 2019
1 parent 159194b commit 575f7f5
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions components/script/dom/htmlformelement.rs
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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<DOMString> = Vec::new();
for elem in sourcedNamesVec.iter() {
Expand Down

0 comments on commit 575f7f5

Please sign in to comment.