diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-03 21:37:06 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-03 21:37:06 +0000 |
commit | 3f1b68384562fe294a1a263214a3fd26ea869bc9 (patch) | |
tree | 21be758e3205fb8c13144c39f3790e380a9e8f5f /javascript/jsapi/dom.bnd | |
parent | 6648ba39ade5ed8c1a5ceccab82eed567478c950 (diff) | |
download | netsurf-3f1b68384562fe294a1a263214a3fd26ea869bc9.tar.gz netsurf-3f1b68384562fe294a1a263214a3fd26ea869bc9.tar.bz2 |
implement dom-getElementsByTagName and nodelist and htmlcollection
Diffstat (limited to 'javascript/jsapi/dom.bnd')
-rw-r--r-- | javascript/jsapi/dom.bnd | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd index 362c828f6..14068ba2e 100644 --- a/javascript/jsapi/dom.bnd +++ b/javascript/jsapi/dom.bnd @@ -7,14 +7,59 @@ operation getElementById %{ dom_element *element; dom_exception exc; - dom_string_create((unsigned char*)elementId, elementId_len, &elementId_dom); + exc = dom_string_create((unsigned char*)elementId, elementId_len, &elementId_dom); + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } exc = dom_document_get_element_by_id(private->node, elementId_dom, &element); - if ((exc == DOM_NO_ERR) && (element != NULL)) { + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } + + if (element != NULL) { jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc); } %} +/* Dom 4 says this should return a htmlcollection, libdom currently + * returns DOM 3 spec of a nodelist + */ + +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; + } + + LOG(("here")); + + exc = dom_document_get_elements_by_tag_name(private->node, localName_dom, /*&collection*/&nodelist); + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } + LOG(("nodelist %p", nodelist)); + + if (/*collection*/nodelist != NULL) { + /* jsret = jsapi_new_HTMLCollection(cx, + NULL, + NULL, + collection, + private->htmlc);*/ + jsret = jsapi_new_NodeList(cx, + NULL, + NULL, + nodelist, + private->htmlc); + } + +%} + getter textContent %{ dom_exception exc; dom_string *content; @@ -24,3 +69,6 @@ getter textContent %{ jsret = JS_NewStringCopyN(cx, dom_string_data(content), dom_string_length(content)); } %} + + + |