mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Implemented {Document,Element}.getElementsByTagName
This commit is contained in:
parent
c768097adc
commit
d22dbb53ca
4 changed files with 11 additions and 6 deletions
|
@ -32,6 +32,7 @@ DOMInterfaces = {
|
|||
'createElement',
|
||||
'createProcessingInstruction',
|
||||
'createTextNode',
|
||||
'getElementsByTagName',
|
||||
'title',
|
||||
],
|
||||
},
|
||||
|
@ -43,6 +44,7 @@ DOMInterfaces = {
|
|||
'attributes',
|
||||
'getBoundingClientRect',
|
||||
'getClientRects',
|
||||
'getElementsByTagName',
|
||||
'id',
|
||||
'innerHTML',
|
||||
'outerHTML',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue