Auto merge of #25456 - pshaughn:pastnamesexpire, r=jdm

Past names expire when form owner is reset

<!-- Please describe your changes on the following line: -->
On their way out of form.controls, elements now also leave form.past_names_map, passing one WPT test. We're already scanning linearly through form.controls linearly to get the index of the control there, so additionally scanning through the past names map by value shouldn't raise any particular performance concern.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25429

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2020-01-08 16:02:44 -05:00 committed by GitHub
commit ed56927faf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -1081,6 +1081,13 @@ impl HTMLFormElement {
.iter()
.position(|c| &**c == control)
.map(|idx| controls.remove(idx));
// https://html.spec.whatwg.org/multipage#forms.html#the-form-element:past-names-map-5
// "If an element listed in a form element's past names map
// changes form owner, then its entries must be removed
// from that map."
let mut past_names_map = self.past_names_map.borrow_mut();
past_names_map.retain(|_k, v| v.0 != control);
}
}