summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsk1994 <rsk1coder99@gmail.com>2014-06-03 05:02:33 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-21 12:07:14 (GMT)
commitfcfdb66ecfb1121f56a849ef087930cac017a5ed (patch)
tree3f7673cea91c19195c8932c38f2936149edda271
parent8bc4bb6abf7f33cb100adacace73997fdb4dc1aa (diff)
downloadlibdom-fcfdb66ecfb1121f56a849ef087930cac017a5ed.tar.gz
libdom-fcfdb66ecfb1121f56a849ef087930cac017a5ed.tar.bz2
OptionElement
-rw-r--r--include/dom/html/html_option_element.h2
-rw-r--r--src/html/TODO4
-rw-r--r--src/html/html_option_element.c19
-rw-r--r--test/testcases/tests/level1/html/HTMLOptionElement05.xml.kfail44
4 files changed, 17 insertions, 52 deletions
diff --git a/include/dom/html/html_option_element.h b/include/dom/html/html_option_element.h
index 53ba286..aa0d11c 100644
--- a/include/dom/html/html_option_element.h
+++ b/include/dom/html/html_option_element.h
@@ -28,7 +28,7 @@ dom_exception dom_html_option_element_get_text(
dom_html_option_element *option, dom_string **text);
dom_exception dom_html_option_element_get_index(
- dom_html_option_element *option, unsigned long *index);
+ dom_html_option_element *option, int32_t *index);
dom_exception dom_html_option_element_get_disabled(
dom_html_option_element *option, bool *disabled);
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;
}
/**
diff --git a/test/testcases/tests/level1/html/HTMLOptionElement05.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement05.xml.kfail
deleted file mode 100644
index 46812a1..0000000
--- a/test/testcases/tests/level1/html/HTMLOptionElement05.xml.kfail
+++ b/dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
-
-<!--
-
-Copyright (c) 2001 World Wide Web Consortium,
-(Massachusetts Institute of Technology, Institut National de
-Recherche en Informatique et en Automatique, Keio University). All
-Rights Reserved. This program is distributed under the W3C's Software
-Intellectual Property License. This program is distributed in the
-hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE.
-
-See W3C License http://www.w3.org/Consortium/Legal/ for more details.
-
--->
-<!DOCTYPE test SYSTEM "dom1.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-1" name="HTMLOptionElement05">
-<metadata>
-<title>HTMLOptionElement05</title>
-<creator>NIST</creator>
-<description>
- The index attribute indicates th index of this OPTION in ints parent
- SELECT.
-
- Retrieve the index attribute from the seventh OPTION element
- and examine its value.
-</description>
-<contributor>Mary Brady</contributor>
-<date qualifier="created">2002-02-22</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-14038413"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="vindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="option" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"option"'/>
-<assertSize collection="nodeList" size="10" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="6"/>
-<index interface="HTMLOptionElement" obj="testNode" var="vindex"/>
-<assertEquals actual="vindex" expected="1" id="indexLink" ignoreCase="false"/>
-</test>