Repository: flex-asjs
Updated Branches:
  refs/heads/refactor-sprite fe03efdf6 -> 8b4b96ab5


Fixed appendChild and removeChild


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/8b4b96ab
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/8b4b96ab
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/8b4b96ab

Branch: refs/heads/refactor-sprite
Commit: 8b4b96ab593ff2fb6f0e4adb21840e5aaab5ad09
Parents: fe03efd
Author: Harbs <ha...@in-tools.com>
Authored: Thu Oct 13 13:22:57 2016 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Thu Oct 13 13:22:57 2016 +0300

----------------------------------------------------------------------
 frameworks/projects/XML/src/main/flex/XML.as    | 32 ++++++++++----------
 .../projects/XML/src/main/flex/XMLList.as       | 32 ++++++++++++++------
 2 files changed, 38 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8b4b96ab/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 3d14a7f..711afb8 100644
--- a/frameworks/projects/XML/src/main/flex/XML.as
+++ b/frameworks/projects/XML/src/main/flex/XML.as
@@ -512,7 +512,7 @@ package
                        for(i=0;i<_attributes.length;i++)
                        {
                                if(_attributes[i].name().matches(attributeName))
-                                       list.appendChild(_attributes[i]);
+                                       list.append(_attributes[i]);
                        }
                        list.targetObject = this;
                        list.targetProperty = attributeName;
@@ -530,7 +530,7 @@ package
                        var i:int;
                        var list:XMLList = new XMLList();
                        for(i=0;i<_attributes.length;i++)
-                               list.appendChild(_attributes[i]);
+                               list.append(_attributes[i]);
 
                        list.targetObject = this;
                        return list;
@@ -569,7 +569,7 @@ package
                        {
                                if(propertyName != "0")
                                        return null;
-                               list.appendChild(this);
+                               list.append(this);
                                list.targetObject = this;
                                return list;
                        }
@@ -579,7 +579,7 @@ package
                                for(i=0;i<_attributes.length;i++)
                                {
                                        
if(propertyName.matches(_attributes[i].name()))
-                                               
list.appendChild(_attributes[i]);
+                                               list.append(_attributes[i]);
                                }
                        }
                        else
@@ -587,7 +587,7 @@ package
                                for(i=0;i<_children.length;i++)
                                {
                                        
if(propertyName.matches(_children[i].name()))
-                                               list.appendChild(_children[i]);
+                                               list.append(_children[i]);
                                }
                        }
                        list.targetObject = this;
@@ -620,7 +620,7 @@ package
                        var i:int;
                        var list:XMLList = new XMLList();
                        for(i=0;i<_children.length;i++)
-                               list.appendChild(_children[i]);
+                               list.append(_children[i]);
 
                        list.targetObject = this;
                        return list;
@@ -639,7 +639,7 @@ package
                        for(i=0;i<_children.length;i++)
                        {
                                if(_children[i].nodeKind() == "comment")
-                                       list.appendChild(_children[i]);
+                                       list.append(_children[i]);
                        }
                        list.targetObject = this;
                        return list;
@@ -650,17 +650,17 @@ package
                        if(list is XML)
                        {
                                var newList:XMLList = new XMLList();
-                               newList.appendChild(list);
+                               newList.append(list);
                                list = newList;
                        }
                        if(!(list is XMLList))
                                throw new TypeError("invalid type");
 
                        var retVal:XMLList = new XMLList();
-                       retVal.appendChild(this);
+                       retVal.append(this);
                        var item:XML;
                        for each(item in list)
-                               retVal.appendChild(item);
+                               retVal.append(item);
                                
                        return retVal;
                }
@@ -768,7 +768,7 @@ package
                                for(i=0;i<_attributes.length;i++)
                                {
                                        if(name.matches(_attributes[i].name()))
-                                               
list.appendChild(_attributes[i]);
+                                               list.append(_attributes[i]);
                                }
                        }
                        for(i=0;i<_children.length;i++)
@@ -776,7 +776,7 @@ package
                                if(_children[i].nodeKind() == "element")
                                {
                                        if(name.matches(_children[i].name()))
-                                               list.appendChild(_children[i]);
+                                               list.append(_children[i]);
 
                                        
list.concat(_children[i].descendants(name));
                                } 
@@ -801,7 +801,7 @@ package
                        for(i=0;i<_children.length;i++)
                        {
                                if(_children[i].nodeKind() == "element" && 
name.matches(_children[i].name()))
-                                       list.appendChild(_children[i]);
+                                       list.append(_children[i]);
                        }
 
                        list.targetObject = this;
@@ -1370,7 +1370,7 @@ package
                public function plus(rightHand:*):*
                {
                        var list:XMLList = new XMLList();
-                       list.appendChild(this);
+                       list.append(this);
                        return list.plus(rightHand);
                }
 
@@ -1403,7 +1403,7 @@ package
                        for(i=0;i<_children.length;i++)
                        {
                                if(_children[i].nodeKind() == 
"processing-instruction")
-                                       list.appendChild(_children[i]);
+                                       list.append(_children[i]);
                        }
                        list.targetObject = this;
                        return list;
@@ -2033,7 +2033,7 @@ package
                        for(i=0;i<_children.length;i++)
                        {
                                if(_children[i].nodeKind() == "text")
-                                       list.appendChild(_attributes[i]);
+                                       list.append(_attributes[i]);
                        }
                        list.targetObject = this;
                        return list;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8b4b96ab/frameworks/projects/XML/src/main/flex/XMLList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/XML/src/main/flex/XMLList.as 
b/frameworks/projects/XML/src/main/flex/XMLList.as
index 7078a55..3136974 100644
--- a/frameworks/projects/XML/src/main/flex/XMLList.as
+++ b/frameworks/projects/XML/src/main/flex/XMLList.as
@@ -115,7 +115,7 @@ package
                                        "get": function():* { return 
_xmlArray[idx]; },
                                        "set": function(newValue:*):void {
                                                if(idx >= _xmlArray.length)
-                                                       appendChild(newValue);
+                                                       append(newValue);
                                                else
                                                        
replaceChildAt(idx,newValue);
                                        },
@@ -125,7 +125,7 @@ package
                        );
                }
                
-               public function appendChild(child:XML):void
+               public function append(child:XML):void
                {
                        _xmlArray[_xmlArray.length] = child;
                        addIndex(_xmlArray.length);
@@ -147,6 +147,13 @@ package
                                
_targetObject.insertChildAfter(objToAppend[objToAppend.length()-1],child);
                        }while(false);
                }
+
+               public function appendChild(child:XML):XML
+               {
+                       if(isSingle())
+                               return _xmlArray[0].appendChild(child);
+                       return null;
+               }
                
                /**
                 * Calls the attribute() method of each XML object and returns 
an XMLList object of the results.
@@ -200,7 +207,7 @@ package
                        {
                                if(propNum >= 0 && propNum < _xmlArray.length)
                                {
-                                       retVal.appendChild(_xmlArray[propNum]);
+                                       retVal.append(_xmlArray[propNum]);
                                        retVal.targetObject = 
_xmlArray[propNum];
                                }
                                return retVal;
@@ -265,7 +272,7 @@ package
                        if(list is XML)
                        {
                                var newList:XMLList = new XMLList();
-                               newList.appendChild(list);
+                               newList.append(list);
                                list = newList;
                        }
                        if(!(list is XMLList))
@@ -276,11 +283,11 @@ package
                        var len:int = list.length();
                        var i:int=0;
                        while(i<len)
-                               appendChild(list[i++]);
+                               append(list[i++]);
 
 //                     var xmlList:XMLList = list;
 //                     for each(item in xmlList)
-//                             appendChild(item);
+//                             append(item);
                                
                        return this;
                }
@@ -315,7 +322,7 @@ package
                        var retVal:XMLList = new XMLList();
                        var len:int = _xmlArray.length;
                        for (var i:int=0;i<len;i++)
-                               retVal.appendChild(_xmlArray[i].copy());
+                               retVal.append(_xmlArray[i].copy());
                        
                        return retVal;
                }
@@ -402,7 +409,7 @@ package
                        for(var i:int = 0;i<_xmlArray.length;i++)
                        {
                                if(callback(_xmlArray[i]))
-                                       list.appendChild(_xmlArray[i]);
+                                       list.append(_xmlArray[i]);
                        }
                        list.targetObject = _targetObject;
                        list.targetProperty = _targetProperty;
@@ -600,10 +607,10 @@ package
                                        continue;
                                if(name == "*")
                                {
-                                       retVal.appendChild(_xmlArray[i]);
+                                       retVal.append(_xmlArray[i]);
                                }
                                else if(name == _xmlArray[i].localName)
-                                       retVal.appendChild(_xmlArray[i]);
+                                       retVal.append(_xmlArray[i]);
                        }
                        return retVal;
                }
@@ -612,6 +619,11 @@ package
                {
                        var i:int;
                        var len:int;
+                       if(child is String)
+                       {
+                               child = this.child(child);
+                       }
+                       
                        if(child is XMLList)
                        {
                                len = child.length();

Reply via email to