Cleanup Document::GetElementsByName.

This commit is contained in:
Ms2ger 2014-12-04 11:40:44 +01:00
parent d22964792a
commit 9416e9b11a

View file

@ -863,11 +863,10 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname
fn GetElementsByName(self, name: DOMString) -> Temporary<NodeList> { fn GetElementsByName(self, name: DOMString) -> Temporary<NodeList> {
self.createNodeList(|node| { self.createNodeList(|node| {
if !node.is_element() { let element: JSRef<Element> = match ElementCast::to_ref(node) {
return false; Some(element) => element,
} None => return false,
};
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
element.get_attribute(ns!(""), &atom!("name")).root().map_or(false, |attr| { element.get_attribute(ns!(""), &atom!("name")).root().map_or(false, |attr| {
attr.value().as_slice() == name.as_slice() attr.value().as_slice() == name.as_slice()
}) })