summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2012-10-06 16:30:42 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2012-10-06 16:30:42 +0100
commit52687feace9d5aabbea30f6ac6dffeb945591716 (patch)
treeaaf8514a1ab46d262c3b5356aaf8c066192b152f /src
parent35068046a8bb4d6d2d6e0dcd08957fe954bbbdd4 (diff)
downloadlibdom-52687feace9d5aabbea30f6ac6dffeb945591716.tar.gz
libdom-52687feace9d5aabbea30f6ac6dffeb945591716.tar.bz2
Fix cloning of element attr list.
Diffstat (limited to 'src')
-rw-r--r--src/core/element.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/element.c b/src/core/element.c
index cbdb6e1..a6ef928 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -289,7 +289,6 @@ static void _dom_element_attr_list_node_destroy(dom_attr_list *n)
doc = a->owner;
if (n->namespace == NULL &&
dom_string_isequal(n->name, doc->class_string)) {
- dom_node_internal *a = (dom_node_internal *)(n->attr);
_dom_element_destroy_classes((dom_element *)(a->parent));
}
@@ -384,10 +383,12 @@ static void _dom_element_attr_list_destroy(dom_attr_list *list)
/**
* Clone an attribute list node, and its attribute
*
- * \param n The attribute list node to clone
+ * \param n The attribute list node to clone
+ * \param newe Element to clone attribute for
* \return the new attribute list node, or NULL on failure
*/
-static dom_attr_list * _dom_element_attr_list_node_clone(dom_attr_list *n)
+static dom_attr_list *_dom_element_attr_list_node_clone(dom_attr_list *n,
+ dom_element *newe)
{
dom_attr *clone = NULL;
dom_attr_list *new_list_node;
@@ -412,6 +413,9 @@ static dom_attr_list * _dom_element_attr_list_node_clone(dom_attr_list *n)
return NULL;
}
+ dom_node_set_parent(clone, newe);
+ dom_node_remove_pending(clone);
+ dom_node_unref(clone);
new_list_node->attr = clone;
if (n->name != NULL)
@@ -427,28 +431,29 @@ static dom_attr_list * _dom_element_attr_list_node_clone(dom_attr_list *n)
* Clone an entire attribute list, and its attributes
*
* \param list The attribute list to clone
+ * \param newe Element to clone list for
* \return the new attribute list, or NULL on failure
*/
-static dom_attr_list * _dom_element_attr_list_clone(dom_attr_list *list)
+static dom_attr_list *_dom_element_attr_list_clone(dom_attr_list *list,
+ dom_element *newe)
{
dom_attr_list *attr = list;
dom_attr_list *new_list = NULL;
dom_attr_list *new_list_node = NULL;
- bool first = true;
if (list == NULL)
return NULL;
do {
- new_list_node = _dom_element_attr_list_node_clone(attr);
+ new_list_node = _dom_element_attr_list_node_clone(attr, newe);
if (new_list_node == NULL) {
if (new_list != NULL)
_dom_element_attr_list_destroy(new_list);
return NULL;
}
- if (first) {
+ if (new_list == NULL) {
new_list = new_list_node;
} else {
_dom_element_attr_list_insert(new_list, new_list_node);
@@ -1536,7 +1541,8 @@ dom_exception _dom_element_copy(dom_node_internal *old,
if (olde->attributes != NULL) {
/* Copy the attribute list */
- e->attributes = _dom_element_attr_list_clone(olde->attributes);
+ e->attributes = _dom_element_attr_list_clone(olde->attributes,
+ e);
} else {
e->attributes = NULL;
}