Skip to content


Browse files Browse the repository at this point in the history
rooted at the form's root, not rooted at the form
  • Loading branch information
pshaughn committed Feb 10, 2020
1 parent 5bcd0d8 commit 0eeb075
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
21 changes: 12 additions & 9 deletions components/script/dom/
Expand Up @@ -5,10 +5,11 @@
use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding;
use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods};
use crate::dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::element::Element;
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
Expand All @@ -21,25 +22,30 @@ use dom_struct::dom_struct;
pub struct HTMLFormControlsCollection {
collection: HTMLCollection,
form: Dom<HTMLFormElement>,

impl HTMLFormControlsCollection {
fn new_inherited(
root: &HTMLFormElement,
form: &HTMLFormElement,
filter: Box<dyn CollectionFilter + 'static>,
) -> HTMLFormControlsCollection {
let root_of_form = form
HTMLFormControlsCollection {
collection: HTMLCollection::new_inherited(root.upcast::<Node>(), filter),
collection: HTMLCollection::new_inherited(&*root_of_form, filter),
form: Dom::from_ref(form),

pub fn new(
window: &Window,
root: &HTMLFormElement,
form: &HTMLFormElement,
filter: Box<dyn CollectionFilter + 'static>,
) -> DomRoot<HTMLFormControlsCollection> {
Box::new(HTMLFormControlsCollection::new_inherited(root, filter)),
Box::new(HTMLFormControlsCollection::new_inherited(form, filter)),
Expand Down Expand Up @@ -80,14 +86,11 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection {
// Step 4-5
let global =;
let window = global.as_window();
// okay to unwrap: root's type was checked in the constructor
let collection_root = self.collection.root_node();
let form = collection_root.downcast::<HTMLFormElement>().unwrap();
// There is only one way to get an HTMLCollection,
// specifically HTMLFormElement::Elements(),
// and the collection filter excludes image inputs.
RadioNodeList::new_controls_except_image_inputs(window, form, name),
RadioNodeList::new_controls_except_image_inputs(window, &*self.form, name),
// Step 3
Expand Down
@@ -1,8 +1,5 @@
type: testharness
[form.elements must contain all listed elements with the form owner]
expected: FAIL

[form.elements only includes elements from the same shadow tree]
expected: FAIL

0 comments on commit 0eeb075

Please sign in to comment.