[gxml] * do not unset all and try to readd the current ones, because we'd be deleting the actual attribute



commit 927485c9b614f346627eed313a3af0c2dad35191
Author: Richard Schwarting <aquarichy gmail com>
Date:   Tue Sep 20 16:16:40 2011 -0400

    * do not unset all and try to readd the current ones, because we'd be deleting the actual attribute data out from underneath the ones that were there from the start.  Instead, just unset libxml2 ones that we don't have GXml attributes for anymore.

 gxml/Element.vala |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 27bc02e..1f190ac 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -127,12 +127,16 @@ namespace GXml.Dom {
 				for (Xml.Attr *xmlattr = this.node->properties; xmlattr != null; xmlattr = xmlattr->next) {
 					// TODO: make sure that this actually works, and that I don't lose my attr->next for the next step by unsetting attr
 					// TODO: need a good test case that makes sure that the properties do not get duplicated, that removed ones stay removed, and new ones appear when recorded to back to a file
-					if (xmlattr->ns == null) {
-						// Attr has no namespace
-						this.node->unset_prop (xmlattr->name);
-					} else {
-						// Attr has a namespace
-						this.node->unset_ns_prop (xmlattr->ns, xmlattr->name);
+					if (this._attributes.lookup (xmlattr->name) == null) {
+						// this element no longer has an attribute with this name, so get rid of the underlying one when syncing
+						if (xmlattr->ns == null) {
+							// Attr has no namespace
+							this.node->unset_prop (xmlattr->name);
+						} else {
+							// Attr has a namespace
+							this.node->unset_ns_prop (xmlattr->ns, xmlattr->name);
+						}
+
 					}
 				}
 				



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]