flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [12/49] git commit: [flex-asjs] [refs/heads/develop] - hasComplexContent(), hasOwnProperty(), hasSimpleContent()
Date Sun, 10 Apr 2016 22:48:23 GMT
hasComplexContent(),hasOwnProperty(),hasSimpleContent()


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

Branch: refs/heads/develop
Commit: cf9de31cff3124407239f832f3913142680d7439
Parents: f6aee89
Author: Harbs <harbs@in-tools.com>
Authored: Sun Feb 7 17:01:19 2016 +0200
Committer: Harbs <harbs@in-tools.com>
Committed: Sun Feb 7 17:01:19 2016 +0200

----------------------------------------------------------------------
 frameworks/projects/XML/as/src/XML.as | 53 ++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/cf9de31c/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 e14f8f0..c2dfbe8 100644
--- a/frameworks/projects/XML/as/src/XML.as
+++ b/frameworks/projects/XML/as/src/XML.as
@@ -870,10 +870,25 @@ package
 		 */
 		public function hasComplexContent():Boolean
 		{
-			return false
+			/*
+				When the hasComplexContent method is called on an XML object x, the following steps are
taken:
+				1. If x.[[Class]] ∈ {"attribute", "comment", "processing-instruction", "text"}, return
false
+				2. For each property p in x
+				a. If p.[[Class]] == "element", return true
+				3. Return false
+			*/
+			if(_nodeKind == "attribute" || _nodeKind == "comment" || _nodeKind == "processing-instruction"
|| _nodeKind == "text")
+				return false;
+			var i:int;
+			for(i=0i<_children.length;i++)
+			{
+				if(_children[i].nodeKind() == "element")
+					return true;
+			}
+			return false;
 		}
 
-		public function hasOwnProperty():Boolean
+		public function hasOwnProperty(p:*):Boolean
 		{
 			/*
 				When the [[HasProperty]] method of an XML object x is called with property name P, the
following steps are taken:
@@ -890,6 +905,23 @@ package
 				    i. Return true
 				5. Return false
 			*/
+			if(parseInt(p,10).toString() == p)
+				return p == "0";
+			var name:QName = toXMLName(p);
+			var i:int;
+			for(i=0;i<_attributes.length;i++)
+			{
+				if(_attributes[i].name().matches(name))
+					return true;
+			}
+			for(i=0;i<_children.length;i++)
+			{
+				if(_children[i].nodeKind() != "element")
+					continue;
+				if(_children[i].name().matches(name))
+					return true;
+			}
+			return false;
 		}
 				
 		/**
@@ -900,7 +932,22 @@ package
 		 */
 		public function hasSimpleContent():Boolean
 		{
-			return false;
+			/*
+				When the hasSimpleContent method is called on an XML object x, the following steps are
taken:
+				1. If x.[[Class]] ∈ {"comment", "processing-instruction"}, return false
+				2. For each property p in x
+				a. If p.[[Class]] == "element", return false
+				3. Return true
+			*/
+			if(_nodeKind == "comment" || _nodeKind == "processing-instruction")
+				return false;
+			var i:int;
+			for(i=0i<_children.length;i++)
+			{
+				if(_children[i].nodeKind() == "element")
+					return false;
+			}
+			return true;
 		}
 		
 		/**


Mime
View raw message