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
fn GetDoctype(self) -> Option<Temporary<DocumentType>> {
let node: JSRef<Node> = NodeCast::from_ref(self);
node.children().find(|child| {
child.is_doctype()
}).map(|node| {
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
Temporary::from_rooted(doctype)
})
node.children()
.filter_map(DocumentTypeCast::to_ref)
.next()
.map(Temporary::from_rooted)
}
// http://dom.spec.whatwg.org/#dom-document-documentelement