Nicolas Cannasse 14 лет назад
Родитель
Сommit
93e79ae8cf
2 измененных файлов с 25 добавлено и 5 удалено
  1. 1 0
      doc/CHANGES.txt
  2. 24 5
      std/flash9/_std/Xml.hx

+ 1 - 0
doc/CHANGES.txt

@@ -39,6 +39,7 @@
 	flash9 : fixed issues with loading a haXe SWF (boot_XXXX class extends flash.Boot)
 	all : allow to inline override methods (if the superclass method is not inlined already)
 	all : fixed escape sequences in literal regular expressions
+	flash9 : fixed Xml.setNodeValue
 
 2010-08-14: 2.06
 	neko : change serializer to be able to handle instances of basic classes from other modules

+ 24 - 5
std/flash9/_std/Xml.hx

@@ -125,17 +125,36 @@ enum XmlType {
 	}
 
 	private function getNodeValue() : String {
-		if( _node.hasComplexContent() )
+		var nodeType = nodeType;
+		if( nodeType == Xml.Element || nodeType == Xml.Document )
 			throw "bad nodeType";
 		return _node.toString();
 	}
 
 	private function setNodeValue( v : String ) : String {
-		if( _node.hasComplexContent() || _node.children() == null )
+		var nodeType = nodeType;
+		var x = null;
+		if( nodeType == Xml.Element || nodeType == Xml.Document )
 			throw "bad nodeType";
-		var children = _node.children();
-		untyped __delete__(children, Reflect.fields(children)[0]);
-		_node.appendChild(new XML(v));
+		else if( nodeType == Xml.PCData )
+			x = createPCData(v);
+		else if( nodeType == Xml.CData )
+			x = createCData(v);
+		else if( nodeType == Xml.Comment )
+			x = createComment(v);
+		else if( nodeType == Xml.DocType )
+			x = createDocType(v);
+		else
+			x = createProlog(v);
+		var p = _node.parent();
+		if( p != null ) {
+			p.insertChildAfter(_node, x._node);
+			var i = _node.childIndex();
+			var children = p.children();
+			untyped __delete__(children, Reflect.fields(children)[i]);
+		}
+		_node = x._node;
+		untyped _map[_node] = this;
 		return v;
 	}