Hi Josh,
Sorry to bother you on a Sunday.
We have added the enum and struct modifications as mentioned above. Listed
below are some issues which we are unclear about:
*1.* As mentioned on the project page, we need to create a *vector*
*(SourcedName,
DomRoot<HTMLElement>)* by iterating over *self.controls* member. This
*vector* is to be used as an *ordered list of structs (string, element,
source)* as specified in step 1 of the spec
<
https://html.spec.whatwg.org/multipage/forms.html#the-form-element:supported-property-names>,
right?
*2.* Currently, we have considered the *vector (SourcedName,
DomRoot<HTMLElement>)* as the *ordered list of structs (string, element,
source)* that we will return as the method output. This snippet iterates
over all the control elements and checks if it is a listed element. We
change the source based on the attribute the child element has and push the
entry to the *vector*. Kindly review the code and let us know if there are
any issues in the code.
* let controls = self.controls.borrow(); // borrow immutable
`controls` member for child in controls.iter() { if
child.is_listed_element() { if
child.has_attribute(&local_name!("id")) { let entry =
SourcedName {name: child.get_string_attribute(&local_name!("id")), element:
child, source: Id}; vec.push(entry, child);
} else if child.has_attribute(&local_name!("name")) {
let entry = SourcedName {name:
child.get_string_attribute(&local_name!("name")), element: child, source:
Name}; vec.push(entry, child); }
} }*
For step 3 related to image buttons, the function call *if
child.is_listed_element()* is replaced by *if
child.get_string_attribute(&local_name!("type")) == "image" **.*
*3.* In which function do we add the entries in the map and how do we
implement the past names map exactly? We read through the issue but
couldn't understand exactly the way in which we will implement it.
These are a lot of questions but we would greatly appreciate your
inputs. Thank you.
Regards
Chintan Gandhi
NC State University
On Thu, Nov 28, 2019 at 10:31 AM Josh Bowman-Matthews <
jo...@joshmatthews.net>
wrote:
> Great question! I recommend representing it like:
>
> enum SourcedNameSource {
> Id,
> Name,
> Past(Duration)
> }
>
> struct SourcedName {
> name: String,
> element: DomRoot<Element>,
> source: SourcedNameSource,
> }
>
> This will allow you to access the values that are always present as
> named fields of the entry, and then use the `match` language feature to
> access the values that can change depending on what kind of source it is.
>
> For fetching the id and name attribute values, you will need the
> Element::get_string_attribute API
> (
>
https://doc.servo.org/script/dom/element/struct.Element.html#method.get_string_attribute),
>
> and you will pass a value like `&local_name!("id")`.
>
> Cheers,
> Josh
>
> On 11/28/19 2:07 AM, Chintan Gandhi wrote: