From 3ea1b30fd6b08ed3b4b139c1d87d0530e7303a83 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 23 Dec 2005 00:59:56 +0100 Subject: [PATCH] Fix matching of the :root structural pseudo-class Root nodes either have no parents or are the single child of the document node. --- src/document/dom/select.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/document/dom/select.c b/src/document/dom/select.c index eda88861..1bbaed9d 100644 --- a/src/document/dom/select.c +++ b/src/document/dom/select.c @@ -738,10 +738,14 @@ match_element_selector(struct dom_select_node *selector, struct dom_node *node) break; } - /* Root node are rooted at the don't have parent nodes. */ + /* Root nodes either have no parents or are the single child of the + * document node. */ if (has_element_match(selector, DOM_SELECT_ELEMENT_ROOT) - && node->parent) - return 0; + && node->parent) { + if (node->parent->type != DOM_NODE_DOCUMENT + || node->parent->children->size > 1) + return 0; + } if (has_element_match(selector, DOM_SELECT_ELEMENT_EMPTY) && node->data.element.map->size > 0)