From fab7b04de689fdbb03e4cf604b1524a80bb4a174 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 23 Jan 2013 14:11:41 +0000 Subject: implement Element::getElementsByTagName --- javascript/jsapi/htmldocument.bnd | 1 + javascript/jsapi/htmlelement.bnd | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index c948e2dbb..ec7a18039 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -219,6 +219,7 @@ operation getElementById %{ * Dom 4 says this should return a htmlcollection, libdom currently * returns DOM 3 spec of a nodelist */ +/* HTMLCollection Document::getElementsByTagName(DOMString localName); */ operation getElementsByTagName %{ dom_string *localName_dom; /* dom_html_collection *collection;*/ diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index f0032fa1a..5af2d5b25 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -174,6 +174,44 @@ operation setAttribute %{ } %} +/* + * + * Dom 4 says this should return a htmlcollection, libdom currently + * returns DOM 3 spec of a nodelist + */ +/* HTMLCollection Element::getElementsByTagName(DOMString localName); */ +operation getElementsByTagName %{ + dom_string *localName_dom; + /* dom_html_collection *collection;*/ + dom_nodelist *nodelist; + dom_exception exc; + + exc = dom_string_create((uint8_t *)localName, localName_len, &localName_dom); + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } + + exc = dom_element_get_elements_by_tag_name(private->node, localName_dom, /*&collection*/&nodelist); + dom_string_unref(localName_dom); + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } + + if (/*collection*/nodelist != NULL) { + /*jsret = jsapi_new_HTMLCollection(cx, + NULL, + NULL, + collection, + private->htmlc);*/ + jsret = jsapi_new_NodeList(cx, + NULL, + NULL, + nodelist, + private->htmlc); + } + +%} + /* * DOM 3 has these as the element traversal extension * -- cgit v1.2.3