You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2016/04/11 00:48:18 UTC

[07/49] git commit: [flex-asjs] [refs/heads/develop] - children() and elements()

children() and elements()


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

Branch: refs/heads/develop
Commit: 988296e56876807c75b4950b364519f6cff3070f
Parents: 94281ae
Author: Harbs <ha...@in-tools.com>
Authored: Wed Feb 3 23:06:53 2016 +0200
Committer: Harbs <ha...@in-tools.com>
Committed: Wed Feb 3 23:06:53 2016 +0200

----------------------------------------------------------------------
 frameworks/projects/XML/as/src/XML.as     | 21 ++++++++++++++------
 frameworks/projects/XML/as/src/XMLList.as | 27 ++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/988296e5/frameworks/projects/XML/as/src/XML.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/XML/as/src/XML.as b/frameworks/projects/XML/as/src/XML.as
index dc99ff9..8be71e2 100644
--- a/frameworks/projects/XML/as/src/XML.as
+++ b/frameworks/projects/XML/as/src/XML.as
@@ -566,11 +566,8 @@ package
 		{
 			var list:XMLList = new XMLList();
 			for(i=0;i<_children.length;i++)
-			{
-				//TODO filter out non-elements
-				if(propertyName.matches(_children[i].name()))
-					list.append(_children[i]);
-			}
+				list.append(_children[i]);
+
 			list.targetObject = this;
 			return list;
 		}
@@ -682,7 +679,7 @@ package
 		}
 		
 		/**
-		 * Lists the elements of an XML object.
+		 * Lists the elements of an XML object. (handles E4X dot notation)
 		 * 
 		 * @param name
 		 * @return 
@@ -690,6 +687,18 @@ package
 		 */
 		public function elements(name:Object = "*"):XMLList
 		{
+			name = toXMLName(name);
+			var list:XMLList = new XMLList();
+			for(i=0;i<_children.length;i++)
+			{
+				if(_children[i].nodeKind() == "element" && name.matches(_children[i].name()))
+					list.append(_children[i]);
+			}
+
+			list.targetObject = this;
+			list.targetProperty = name;
+			return list;
+
 			return null;
 		}
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/988296e5/frameworks/projects/XML/as/src/XMLList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/XML/as/src/XMLList.as b/frameworks/projects/XML/as/src/XMLList.as
index 9e0d2fb..264ef3c 100644
--- a/frameworks/projects/XML/as/src/XMLList.as
+++ b/frameworks/projects/XML/as/src/XMLList.as
@@ -338,6 +338,33 @@ package
 			}
 			return retVal;
 		}
+
+		public function equals(list:*):Boolean
+		{
+			/*
+				Overview
+				The XMLList type adds the internal [[Equals]] method to the internal properties defined by the Object type.
+				The XMLList [[Equals]] method is used to compare this XMLList object for content equality 
+				with another XMLList object V or determine whether this XMLList object contains a single XML object that compares equal to V. 
+				The [[Equals]] operator returns true if this XMLList object is considered equal to V 
+				or contains only one XML object that is considered equal to V. Otherwise, it returns false. 
+				Empty XMLList objects are considered equal to undefined. 
+				The input argument V may be a value of type XMLList, XML, undefined or any value that can be converted to a String with ToString().
+				
+				Semantics
+				When the [[Equals]] method of an XML object x is called with value V, the following steps are taken:
+				1. If V == undefined and x.[[Length]] == 0, return true
+				2. If Type(V) is XMLList
+				  a. If x.[[Length]] is not equal to V.[[Length]], return false
+				  b. For i = 0 to x.[[Length]]
+				    i. If the result of the comparison x[i] == V[i] is false, return false
+				  c. Return true
+				3. Else if x.[[Length]] == 1
+				  a. Return the result of the comparison x[0] == V
+				4. Return false
+			*/
+			return false;
+		}
 		
 		public function hasComplexContent():Boolean
 		{