use dom_struct::dom_struct;
use crate::dom::bindings::codegen::Bindings::DOMStringListBinding::DOMStringListMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::window::Window;
#[dom_struct]
pub struct DOMStringList {
reflector_: Reflector,
strings: Vec<DOMString>,
}
impl DOMStringList {
#[allow(unused)]
pub fn new_inherited(strings: Vec<DOMString>) -> DOMStringList {
DOMStringList {
reflector_: Reflector::new(),
strings,
}
}
#[allow(unused)]
pub fn new(window: &Window, strings: Vec<DOMString>) -> DomRoot<DOMStringList> {
reflect_dom_object(Box::new(DOMStringList::new_inherited(strings)), window)
}
}
impl DOMStringListMethods for DOMStringList {
fn Length(&self) -> u32 {
self.strings.len() as u32
}
fn Item(&self, index: u32) -> Option<DOMString> {
self.strings.get(index as usize).cloned()
}
fn Contains(&self, string: DOMString) -> bool {
self.strings.contains(&string)
}
fn IndexedGetter(&self, index: u32) -> Option<DOMString> {
self.Item(index)
}
}