aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/radionodelist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/radionodelist.rs')
-rw-r--r--components/script/dom/radionodelist.rs37
1 files changed, 26 insertions, 11 deletions
diff --git a/components/script/dom/radionodelist.rs b/components/script/dom/radionodelist.rs
index d178921056a..21b7d39772b 100644
--- a/components/script/dom/radionodelist.rs
+++ b/components/script/dom/radionodelist.rs
@@ -8,11 +8,12 @@ use crate::dom::bindings::codegen::Bindings::RadioNodeListBinding;
use crate::dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::reflect_dom_object;
-use crate::dom::bindings::root::{Dom, DomRoot};
+use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
+use crate::dom::htmlformelement::HTMLFormElement;
use crate::dom::htmlinputelement::{HTMLInputElement, InputType};
use crate::dom::node::Node;
-use crate::dom::nodelist::{NodeList, NodeListType};
+use crate::dom::nodelist::{NodeList, NodeListType, RadioList, RadioListMode};
use crate::dom::window::Window;
use dom_struct::dom_struct;
@@ -38,18 +39,33 @@ impl RadioNodeList {
)
}
- pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<RadioNodeList>
- where
- T: Iterator<Item = DomRoot<Node>>,
- {
+ pub fn new_controls_except_image_inputs(
+ window: &Window,
+ form: &HTMLFormElement,
+ name: DOMString,
+ ) -> DomRoot<RadioNodeList> {
RadioNodeList::new(
window,
- NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect()),
+ NodeListType::Radio(RadioList::new(
+ form,
+ RadioListMode::ControlsExceptImageInputs,
+ name,
+ )),
)
}
- // FIXME: This shouldn't need to be implemented here since NodeList (the parent of
- // RadioNodeList) implements Length
+ pub fn new_images(
+ window: &Window,
+ form: &HTMLFormElement,
+ name: DOMString,
+ ) -> DomRoot<RadioNodeList> {
+ RadioNodeList::new(
+ window,
+ NodeListType::Radio(RadioList::new(form, RadioListMode::Images, name)),
+ )
+ }
+
+ // https://dom.spec.whatwg.org/#dom-nodelist-length
// https://github.com/servo/servo/issues/5875
pub fn Length(&self) -> u32 {
self.node_list.Length()
@@ -60,7 +76,6 @@ impl RadioNodeListMethods for RadioNodeList {
// https://html.spec.whatwg.org/multipage/#dom-radionodelist-value
fn Value(&self) -> DOMString {
self.upcast::<NodeList>()
- .as_simple_list()
.iter()
.filter_map(|node| {
// Step 1
@@ -85,7 +100,7 @@ impl RadioNodeListMethods for RadioNodeList {
// https://html.spec.whatwg.org/multipage/#dom-radionodelist-value
fn SetValue(&self, value: DOMString) {
- for node in self.upcast::<NodeList>().as_simple_list().iter() {
+ for node in self.upcast::<NodeList>().iter() {
// Step 1
if let Some(input) = node.downcast::<HTMLInputElement>() {
match input.input_type() {