summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-09-23 00:37:44 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-09-23 00:37:44 +0000
commitbe0d8b580dd64fce2398d911adcbac9665369a7b (patch)
tree4ba7e89fbb69ad0b20f298ffe313a69a0437b380 /src/core
parent536f38a4aa7872e7801f5afebbc5659ad9c5264c (diff)
downloadlibdom-be0d8b580dd64fce2398d911adcbac9665369a7b.tar.gz
libdom-be0d8b580dd64fce2398d911adcbac9665369a7b.tar.bz2
Fix dom_node_get_parent_node(), dom_node_get_previous_sibling() and dom_node_get_next_sibling() to return NULL for Attr nodes.
svn path=/trunk/dom/; revision=3579
Diffstat (limited to 'src/core')
-rw-r--r--src/core/node.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/node.c b/src/core/node.c
index 8d1f16a..3a8af63 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -391,6 +391,12 @@ dom_exception dom_node_get_node_type(struct dom_node *node,
dom_exception dom_node_get_parent_node(struct dom_node *node,
struct dom_node **result)
{
+ /* Attr nodes have no parent */
+ if (node->type == DOM_ATTRIBUTE_NODE) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
/* If there is a parent node, then increase its reference count */
if (node->parent != NULL)
dom_node_ref(node->parent);
@@ -484,6 +490,12 @@ dom_exception dom_node_get_last_child(struct dom_node *node,
dom_exception dom_node_get_previous_sibling(struct dom_node *node,
struct dom_node **result)
{
+ /* Attr nodes have no previous siblings */
+ if (node->type == DOM_ATTRIBUTE_NODE) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
/* If there is a previous sibling, increase its reference count */
if (node->previous != NULL)
dom_node_ref(node->previous);
@@ -507,6 +519,12 @@ dom_exception dom_node_get_previous_sibling(struct dom_node *node,
dom_exception dom_node_get_next_sibling(struct dom_node *node,
struct dom_node **result)
{
+ /* Attr nodes have no next siblings */
+ if (node->type == DOM_ATTRIBUTE_NODE) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
/* If there is a subsequent sibling, increase its reference count */
if (node->next != NULL)
dom_node_ref(node->next);