From ac0a6be4a62b2fa9830184def0652a499df1398b Mon Sep 17 00:00:00 2001 From: rsk1994 Date: Tue, 3 Jun 2014 10:32:33 +0530 Subject: OptionElement --- src/html/TODO | 4 ++-- src/html/html_option_element.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/html/TODO b/src/html/TODO index 8e004e1..6a3d190 100644 --- a/src/html/TODO +++ b/src/html/TODO @@ -13,8 +13,8 @@ HTMLStyleElement html_style_element DONE HTMLBodyElement html_body_element MISSING HTMLFormElement html_form_element DONE HTMLSelectElement html_select_element DONE -HTMLOptGroupElement html_optgroup_element MISSING -HTMLOptionElement html_option_element MISSING +HTMLOptGroupElement html_optgroup_element DONE +HTMLOptionElement html_option_element DONE HTMLInputElement html_input_element MISSING HTMLTextAreaElement html_textarea_element MISSING HTMLButtonElement html_button_element MISSING diff --git a/src/html/html_option_element.c b/src/html/html_option_element.c index b133deb..b777c5f 100644 --- a/src/html/html_option_element.c +++ b/src/html/html_option_element.c @@ -255,13 +255,22 @@ dom_exception dom_html_option_element_get_text( * \return DOM_NO_ERR on success, appropriate error otherwise. */ dom_exception dom_html_option_element_get_index( - dom_html_option_element *option, unsigned long *index) + dom_html_option_element *option, int32_t *index) { - UNUSED(option); - UNUSED(index); + dom_html_document *doc = (dom_html_document *) dom_node_get_owner(option); + int32_t idx = 0; + dom_node_internal *n = ((dom_node_internal *)option)->parent; - /** \todo Implement */ - return DOM_NOT_SUPPORTED_ERR; + for(n = n->first_child;n != NULL; n = n->next) { + if((dom_node_internal *)option == n) { + *index = idx; + break; + } else if(dom_string_caseless_isequal(n->name,doc->memoised[hds_OPTION])) { + idx += 1; + } + } + + return DOM_NO_ERR; } /** -- cgit v1.2.3