@@ -1739,7 +1739,7 @@ + (void)removeAllNamespacesFromNode:(xmlNodePtr)node
1739
1739
* The attribute's surrounding prev/next pointers are properly updated to remove the attribute from the attr list.
1740
1740
* Then, if the clean flag is YES, the attribute's parent, prev, next and doc pointers are set to null.
1741
1741
**/
1742
- + (void )detachAttribute : (xmlAttrPtr)attr andClean : (BOOL )flag
1742
+ + (void )detachAttribute : (xmlAttrPtr)attr andClean : (BOOL )clean
1743
1743
{
1744
1744
xmlNodePtr parent = attr->parent ;
1745
1745
@@ -1769,7 +1769,7 @@ + (void)detachAttribute:(xmlAttrPtr)attr andClean:(BOOL)flag
1769
1769
}
1770
1770
}
1771
1771
1772
- if (flag )
1772
+ if (clean )
1773
1773
{
1774
1774
// Nullify pointers
1775
1775
attr->parent = NULL ;
@@ -1834,7 +1834,7 @@ + (void)removeAllAttributesFromNode:(xmlNodePtr)node
1834
1834
* The child's surrounding prev/next pointers are properly updated to remove the child from the node's children list.
1835
1835
* Then, if the clean flag is YES, the child's parent, prev, next and doc pointers are set to null.
1836
1836
**/
1837
- + (void )detachChild : (xmlNodePtr)child andClean : (BOOL )flag
1837
+ + (void )detachChild : (xmlNodePtr)child andClean : (BOOL )clean andFixNamespaces : ( BOOL ) fixNamespaces
1838
1838
{
1839
1839
xmlNodePtr parent = child->parent ;
1840
1840
@@ -1866,11 +1866,14 @@ + (void)detachChild:(xmlNodePtr)child andClean:(BOOL)flag
1866
1866
}
1867
1867
}
1868
1868
1869
- if (flag )
1869
+ if (fixNamespaces )
1870
1870
{
1871
1871
// Fix namesapces (namespace references that now point outside tree)
1872
+ // Note: This must be done before we nullify pointers so we can search up the tree.
1872
1873
[self recursiveFixDefaultNamespacesInNode: child withNewRoot: child];
1873
-
1874
+ }
1875
+ if (clean)
1876
+ {
1874
1877
// Nullify pointers
1875
1878
child->parent = NULL ;
1876
1879
child->prev = NULL ;
@@ -1886,7 +1889,7 @@ + (void)detachChild:(xmlNodePtr)child andClean:(BOOL)flag
1886
1889
**/
1887
1890
+ (void )detachChild : (xmlNodePtr)child
1888
1891
{
1889
- [self detachChild: child andClean: YES ];
1892
+ [self detachChild: child andClean: YES andFixNamespaces: YES ];
1890
1893
}
1891
1894
1892
1895
/* *
@@ -1905,7 +1908,7 @@ + (void)removeChild:(xmlNodePtr)child
1905
1908
1906
1909
// We perform a bit of optimization here.
1907
1910
// No need to bother nullifying pointers since we're about to free the node anyway.
1908
- [self detachChild: child andClean: NO ];
1911
+ [self detachChild: child andClean: NO andFixNamespaces: NO ];
1909
1912
1910
1913
xmlFreeNode (child);
1911
1914
}
0 commit comments