]> granicus.if.org Git - php/commitdiff
- let DomNode->replace_child always behave correctly (acc. to W3C specs)
authorChristian Stocker <chregu@php.net>
Wed, 14 Aug 2002 17:38:20 +0000 (17:38 +0000)
committerChristian Stocker <chregu@php.net>
Wed, 14 Aug 2002 17:38:20 +0000 (17:38 +0000)
if the newchild had the same parent as the old child, nothing happened,
which seemed strange behaviout to me...

ext/domxml/php_domxml.c

index 039c95648da9aa183541adb0c41849772754967a..c656a1afd5824358e82d5726fceac7361423baa3 100644 (file)
@@ -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;
        }