Cleanup Document::GetDoctype.

This commit is contained in:
Ms2ger 2014-12-04 09:43:40 +01:00
parent 90b0369cdf
commit 41395412eb

View file

@ -520,12 +520,10 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-doctype // http://dom.spec.whatwg.org/#dom-document-doctype
fn GetDoctype(self) -> Option<Temporary<DocumentType>> { fn GetDoctype(self) -> Option<Temporary<DocumentType>> {
let node: JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(self);
node.children().find(|child| { node.children()
child.is_doctype() .filter_map(DocumentTypeCast::to_ref)
}).map(|node| { .next()
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap(); .map(Temporary::from_rooted)
Temporary::from_rooted(doctype)
})
} }
// http://dom.spec.whatwg.org/#dom-document-documentelement // http://dom.spec.whatwg.org/#dom-document-documentelement