Fixed moving child xml between parents
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f92aba37 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f92aba37 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f92aba37 Branch: refs/heads/feature/amf Commit: f92aba37f7ba9435cb6929dab61a7c85dfa65d0a Parents: 6000f36 Author: Harbs <[email protected]> Authored: Wed Sep 6 10:56:23 2017 +0300 Committer: Harbs <[email protected]> Committed: Wed Sep 6 10:56:23 2017 +0300 ---------------------------------------------------------------------- frameworks/projects/XML/src/main/flex/XML.as | 3 +-- manualtests/XMLTest/src/MyInitialView.mxml | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f92aba37/frameworks/projects/XML/src/main/flex/XML.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/XML/src/main/flex/XML.as b/frameworks/projects/XML/src/main/flex/XML.as index 7e749fc..fff4cfa 100644 --- a/frameworks/projects/XML/src/main/flex/XML.as +++ b/frameworks/projects/XML/src/main/flex/XML.as @@ -2121,10 +2121,9 @@ package if(parent == _parent) return; var oldParent:XML = _parent; - _parent = parent; - //assign first to prevent the possiblity of a recursive loop if(oldParent) oldParent.removeChild(this); + _parent = parent; } public function setValue(value:String):void http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f92aba37/manualtests/XMLTest/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/manualtests/XMLTest/src/MyInitialView.mxml b/manualtests/XMLTest/src/MyInitialView.mxml index 851aeac..6746727 100644 --- a/manualtests/XMLTest/src/MyInitialView.mxml +++ b/manualtests/XMLTest/src/MyInitialView.mxml @@ -122,6 +122,16 @@ limitations under the License. trace(pop.toString()); trace(xml1.toString()); + var parent:XML = <parent/>; + var childXML:XML = <child/>; + parent.appendChild(childXML); + trace(childXML.toXMLString() + " is child of" + parent.toXMLString() + "? " + (childXML.parent() == parent)); + var newParent:XML = <newparent/>; + newParent.appendChild(childXML); + trace("moving to <newparent/>"); + trace(childXML.toXMLString() + " is child of" + parent.toXMLString() + "? " + (childXML.parent() == parent)); + trace(childXML.toXMLString() + " is child of" + newParent.toXMLString() + "? " + (childXML.parent() == newParent)); + var xmlString:String = xml.toXMLString(); var script:XML = xml..script[0].children()[0]; @@ -266,4 +276,4 @@ limitations under the License. <js:TextButton text="Test" click="runTest()" /> </js:Container> -</js:View> +</js:View> \ No newline at end of file
