diff options
author | Rupinder Singh Khokhar <rsk1coder99@gmail.com> | 2014-06-09 09:33:23 +0530 |
---|---|---|
committer | Rupinder Singh Khokhar <rsk1coder99@gmail.com> | 2014-06-21 17:37:15 +0530 |
commit | 3129c7484a84589794e437e071aa09888e7cbd4a (patch) | |
tree | 490ba676cbea7e86cfe5eaff3cc49b9642ecba49 /src/html | |
parent | f4e634e8d356f199657de358c2e48d4b8065ee36 (diff) | |
download | libdom-3129c7484a84589794e437e071aa09888e7cbd4a.tar.gz libdom-3129c7484a84589794e437e071aa09888e7cbd4a.tar.bz2 |
HTMLCollection
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/html_collection.c | 25 | ||||
-rw-r--r-- | src/html/html_document.c | 1 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/html/html_collection.c b/src/html/html_collection.c index 2b4d8aa..43a26c5 100644 --- a/src/html/html_collection.c +++ b/src/html/html_collection.c @@ -11,6 +11,7 @@ #include <libwapcaplet/libwapcaplet.h> #include "html/html_collection.h" +#include "html/html_document.h" #include "core/node.h" #include "core/element.h" @@ -182,7 +183,7 @@ dom_exception dom_html_collection_item(dom_html_collection *col, /* No children and siblings */ struct dom_node_internal *parent = n->parent; - while (parent != col->root && + while (n != col->root && n == parent->last_child) { n = parent; parent = parent->parent; @@ -212,8 +213,8 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col, dom_string *name, struct dom_node **node) { struct dom_node_internal *n = col->root; + dom_html_document *doc = (dom_html_document *)dom_node_get_owner(n); dom_exception err; - while (n != NULL) { if (n->type == DOM_ELEMENT_NODE && col->ic(n, col->ctx) == true) { @@ -235,6 +236,22 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col, if (id != NULL) dom_string_unref(id); + + /* Check for Name attr if id not matched/found */ + dom_string *id_name = NULL; + err = _dom_element_get_attribute((dom_element *)n, + doc->memoised[hds_name], &id_name); + if(err != DOM_NO_ERR) { + return err; + } + if (id_name != NULL && dom_string_isequal(name, id_name)) { + *node = (struct dom_node *) n; + dom_node_ref(n); + dom_string_unref(id_name); + + return DOM_NO_ERR; + } + } /* Depth first iterating */ @@ -246,13 +263,13 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col, /* No children and siblings */ struct dom_node_internal *parent = n->parent; - while (parent != col->root && + while (n != col->root && n == parent->last_child) { n = parent; parent = parent->parent; } - if (parent == col->root) + if (n == col->root) n = NULL; else n = n->next; diff --git a/src/html/html_document.c b/src/html/html_document.c index 83c4801..cd062a2 100644 --- a/src/html/html_document.c +++ b/src/html/html_document.c @@ -907,6 +907,7 @@ dom_exception _dom_html_document_set_cookie(dom_html_document *doc, { UNUSED(doc); UNUSED(cookie); + /*todo implement this after updating client interface */ return DOM_NOT_SUPPORTED_ERR; } |