summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2002-08-14 17:38:20 +0000
committerChristian Stocker <chregu@php.net>2002-08-14 17:38:20 +0000
commit5c935cb372c55f1a1eaf1672cf3523f777b6de1a (patch)
tree8391bca064766661cf720195c359071a8fecab18
parentb22a1eb93572f978362b6037db2bc148f528387e (diff)
downloadphp-git-5c935cb372c55f1a1eaf1672cf3523f777b6de1a.tar.gz
- let DomNode->replace_child always behave correctly (acc. to W3C specs)
if the newchild had the same parent as the old child, nothing happened, which seemed strange behaviout to me...
-rw-r--r--ext/domxml/php_domxml.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c
index 039c95648d..c656a1afd5 100644
--- a/ext/domxml/php_domxml.c
+++ b/ext/domxml/php_domxml.c
@@ -2512,29 +2512,17 @@ PHP_FUNCTION(domxml_node_replace_child)
if (children == oldchild) {
foundoldchild = 1;
}
- if(children == newchild) {
- foundnewchild = 1;
- }
children = children->next;
}
/* if the child to replace is existent and the new child isn't already
* a child, then do the replacement
*/
- if(foundoldchild && !foundnewchild) {
+ if(foundoldchild ) {
zval *rv = NULL;
xmlNodePtr node;
node = xmlReplaceNode(oldchild, newchild);
DOMXML_RET_OBJ(rv, oldchild, &ret);
return;
- }
- /* If the new child is already a child, then DOM requires to delete
- * the old one first, but this makes no sense here, since the old and
- * the new node are identical.
- */
- if(foundnewchild) {
- zval *rv = NULL;
- DOMXML_RET_OBJ(rv, newchild, &ret);
- return;
} else {
RETURN_FALSE;
}