aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-02-27 13:14:02 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-03-07 11:10:55 -0400
commitd22dbb53ca4bbbf3867d87f9d80059473bd48880 (patch)
tree41ca03ce00bad5d31884fca9b97aa755d26e9625 /src/components/script
parentc768097adc6366dd60319aeaccc4f7e2f883e9f6 (diff)
downloadservo-d22dbb53ca4bbbf3867d87f9d80059473bd48880.tar.gz
servo-d22dbb53ca4bbbf3867d87f9d80059473bd48880.zip
Implemented {Document,Element}.getElementsByTagName
Diffstat (limited to 'src/components/script')
-rw-r--r--src/components/script/dom/bindings/codegen/Bindings.conf2
-rw-r--r--src/components/script/dom/document.rs4
-rw-r--r--src/components/script/dom/element.rs7
-rw-r--r--src/components/script/dom/htmlcollection.rs4
4 files changed, 11 insertions, 6 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf
index 3420e40a4dd..36dbf48a6e8 100644
--- a/src/components/script/dom/bindings/codegen/Bindings.conf
+++ b/src/components/script/dom/bindings/codegen/Bindings.conf
@@ -32,6 +32,7 @@ DOMInterfaces = {
'createElement',
'createProcessingInstruction',
'createTextNode',
+ 'getElementsByTagName',
'title',
],
},
@@ -43,6 +44,7 @@ DOMInterfaces = {
'attributes',
'getBoundingClientRect',
'getClientRects',
+ 'getElementsByTagName',
'id',
'innerHTML',
'outerHTML',
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 2a81d08f4a5..9190e36b0dd 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -212,8 +212,8 @@ impl Document {
}
// http://dom.spec.whatwg.org/#dom-document-getelementsbytagname
- pub fn GetElementsByTagName(&self, tag: DOMString) -> JS<HTMLCollection> {
- self.createHTMLCollection(|elem| elem.get().tag_name == tag)
+ pub fn GetElementsByTagName(&self, abstract_self: &JS<Document>, tag_name: DOMString) -> JS<HTMLCollection> {
+ HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), tag_name)
}
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 4ff7872aa80..108d9aed19e 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -503,11 +503,10 @@ impl Element {
self.GetAttributeNS(namespace, local_name).is_some()
}
- // http://dom.spec.whatwg.org/#dom-element-getelementsbytagname
- pub fn GetElementsByTagName(&self, _localname: DOMString) -> JS<HTMLCollection> {
- // FIXME: stub - https://github.com/mozilla/servo/issues/1660
+ pub fn GetElementsByTagName(&self, abstract_self: &JS<Element>, localname: DOMString) -> JS<HTMLCollection> {
let doc = self.node.owner_doc();
- HTMLCollection::new(&doc.get().window, ~[])
+ let doc = doc.get();
+ HTMLCollection::by_tag_name(&doc.window, &NodeCast::from(abstract_self), localname)
}
// http://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens
diff --git a/src/components/script/dom/htmlcollection.rs b/src/components/script/dom/htmlcollection.rs
index 3f176f4bc31..b2a8ca0aa02 100644
--- a/src/components/script/dom/htmlcollection.rs
+++ b/src/components/script/dom/htmlcollection.rs
@@ -46,6 +46,10 @@ impl HTMLCollection {
}
HTMLCollection::new(window, elements)
}
+
+ pub fn by_tag_name(window: &JS<Window>, root: &JS<Node>, tag_name: DOMString) -> JS<HTMLCollection> {
+ HTMLCollection::create(window, root, |elem| elem.get().tag_name == tag_name)
+ }
}
impl HTMLCollection {