aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-01-08 15:26:44 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-01-08 16:44:47 -0400
commitb5eba001efe209bb9f75c7eb61b8affc848bb2e8 (patch)
tree9355983b63cd777af74f47183a43b7332135c764 /src
parent728fb9a7dedf67445e7f12eafb314117efede70d (diff)
downloadservo-b5eba001efe209bb9f75c7eb61b8affc848bb2e8.tar.gz
servo-b5eba001efe209bb9f75c7eb61b8affc848bb2e8.zip
Fix to avoid attribute name clash between Document/HTMLDocument
Use children() instead of traverse_preorder(), and avoid having GetHead() in both Document and HTMLDocument. Closes #1465.
Diffstat (limited to 'src')
-rw-r--r--src/components/script/dom/bindings/codegen/HTMLDocument.webidl2
-rw-r--r--src/components/script/dom/document.rs3
-rw-r--r--src/components/script/dom/htmldocument.rs8
-rw-r--r--src/test/html/content/test_document_head.html11
4 files changed, 14 insertions, 10 deletions
diff --git a/src/components/script/dom/bindings/codegen/HTMLDocument.webidl b/src/components/script/dom/bindings/codegen/HTMLDocument.webidl
index bb209a20bf9..f735e4f5326 100644
--- a/src/components/script/dom/bindings/codegen/HTMLDocument.webidl
+++ b/src/components/script/dom/bindings/codegen/HTMLDocument.webidl
@@ -17,7 +17,7 @@ interface HTMLDocument : Document {
// getter object (DOMString name);
/*[SetterThrows]
attribute HTMLElement? body;*/
- readonly attribute HTMLHeadElement? head;
+ // readonly attribute HTMLHeadElement? head;
readonly attribute HTMLCollection images;
readonly attribute HTMLCollection embeds;
readonly attribute HTMLCollection plugins;
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index c22884ca07d..be4a8f06330 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -306,12 +306,13 @@ impl Document {
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head
pub fn GetHead(&self) -> Option<AbstractNode> {
self.get_html_element().and_then(|root| {
- root.traverse_preorder().find(|child| {
+ root.children().find(|child| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
})
})
}
+ // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body
pub fn GetBody(&self, _: AbstractDocument) -> Option<AbstractNode> {
match self.get_html_element() {
None => None,
diff --git a/src/components/script/dom/htmldocument.rs b/src/components/script/dom/htmldocument.rs
index 57a5c96b7bd..27b5969458e 100644
--- a/src/components/script/dom/htmldocument.rs
+++ b/src/components/script/dom/htmldocument.rs
@@ -33,14 +33,6 @@ impl HTMLDocument {
}
impl HTMLDocument {
- pub fn GetHead(&self) -> Option<AbstractNode> {
- self.parent.GetDocumentElement().and_then(|root| {
- root.traverse_preorder().find(|child| {
- child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
- })
- })
- }
-
pub fn Images(&self) -> @mut HTMLCollection {
self.parent.createHTMLCollection(|elem| eq_slice(elem.tag_name, "img"))
}
diff --git a/src/test/html/content/test_document_head.html b/src/test/html/content/test_document_head.html
index c4384d8f024..1993e297f97 100644
--- a/src/test/html/content/test_document_head.html
+++ b/src/test/html/content/test_document_head.html
@@ -29,6 +29,17 @@
is(new_document.head, new_head, "test2-4, append head to a new document");
}
+ // test3: head's parent should be document element
+ {
+ let new_document = new Document();
+ let html = new_document.createElement("html");
+ let foo = new_document.createElement("foo");
+ let head = new_document.createElement("head");
+ new_document.appendChild(html);
+ html.appendChild(foo);
+ foo.appendChild(head);
+ is(new_document.head, null, "test3-0, head's parent should be document element");
+ }
finish();
</script>
</body>