You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2020/05/06 11:55:47 UTC

[royale-asjs] 04/07: Fix empty XMLList assignment to XML, added 2 tests

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch release/0.9.7
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 2816acd6f37a5591d0bf97afb1352652a15224f8
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed May 6 06:43:36 2020 +1200

    Fix empty XMLList assignment to XML, added 2 tests
---
 frameworks/projects/XML/src/main/royale/XML.as        |  6 ++++--
 .../royale/flexUnitTests/xml/XMLTesterGeneralTest.as  | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index de0278c..6703632 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -2325,6 +2325,7 @@ package
 		/**
 		 *
 		 * @royaleignorecoercion XML
+		 * @royaleignorecoercion XMLList
 		 */
 		public function replaceChildAt(idx:int,v:*):void
 		{
@@ -2374,11 +2375,12 @@ package
 			}
 			else if(v is XMLList)
 			{
+				len = (v as XMLList).length();
+				if (!len) return;
 				//6.
 				if(_children[idx])
 					_children[idx]._parent = null;
-				
-				len = v.length();
+
 				v[0].setParent(this);
 				_children[idx] = v[0];
 				var listIdx:int = 1;
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
index fd6c175..d0f18f2 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
@@ -1274,6 +1274,25 @@ package flexUnitTests.xml
                    , 'unexpected dest toXMLString');
 
         }
+
+
+        [Test]
+        public function testAssignXMLListVariants():void{
+            var xmlList:XMLList = new XMLList()
+            var xml:XML = <root><foo/></root>;
+            xml.foobaz = xmlList;
+            assertEquals(xml.toXMLString(), '<root>\n' +
+                    '  <foo/>\n' +
+                    '</root>', 'unexpected empty XMLList assignment')
+            xmlList = new XMLList('<foobazzer/><foobazzer/>')
+            xml.foobaz = xmlList;
+            assertEquals(xml.toXMLString(), '<root>\n' +
+                    '  <foo/>\n' +
+                    '  <foobazzer/>\n' +
+                    '  <foobazzer/>\n' +
+                    '</root>', 'unexpected  XMLList assignment')
+
+        }
         
         //@todo - Passes in Swf, fails in browser:
         /*[Test]