mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
parent
99f24fbd40
commit
742ad9cd24
3 changed files with 29 additions and 1 deletions
|
@ -33,7 +33,7 @@ interface Document : Node {
|
|||
// readonly attribute DOMString characterSet;
|
||||
// readonly attribute DOMString contentType;
|
||||
|
||||
//readonly attribute DocumentType? doctype;
|
||||
readonly attribute DocumentType? doctype;
|
||||
readonly attribute Element? documentElement;
|
||||
HTMLCollection getElementsByTagName(DOMString localName);
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
|
|
|
@ -156,6 +156,10 @@ impl Reflectable for Document {
|
|||
}
|
||||
|
||||
impl Document {
|
||||
pub fn GetDoctype(&self) -> Option<AbstractNode> {
|
||||
self.node.children().find(|child| child.is_doctype())
|
||||
}
|
||||
|
||||
pub fn GetDocumentElement(&self) -> Option<AbstractNode> {
|
||||
self.node.child_elements().next()
|
||||
}
|
||||
|
|
24
src/test/html/content/test_document_doctype.html
Normal file
24
src/test/html/content/test_document_doctype.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!-- comment -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="harness.js"></script>
|
||||
<script>
|
||||
// test1: document with doctype
|
||||
{
|
||||
isnot(document.doctype, document.firstChild, "test1-0, document with doctype");
|
||||
isnot(document.doctype, null, "test1-1, document with doctype");
|
||||
is_a(document.doctype, DocumentType, "test1-2, document with doctype");
|
||||
}
|
||||
|
||||
// test2: empty document
|
||||
{
|
||||
var newdoc = new Document();
|
||||
newdoc.appendChild(newdoc.createElement("html"));
|
||||
is(newdoc.doctype, null, "test2-0, empty document");
|
||||
}
|
||||
|
||||
finish();
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue