Fixed hasOwnProperty

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

Branch: refs/heads/feature/strand-work
Commit: 93c980ddf90deb1805ea9b69bf46c0602db46ce1
Parents: 96ee542
Author: Harbs <ha...@in-tools.com>
Authored: Sun Jul 30 22:58:32 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Sun Jul 30 22:58:32 2017 +0300

----------------------------------------------------------------------
 frameworks/projects/XML/src/main/flex/XML.as | 26 ++++++++++++++---------
 manualtests/XMLTest/src/MyInitialView.mxml   |  3 +++
 2 files changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93c980dd/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 b075f2e..f09a018 100644
--- a/frameworks/projects/XML/src/main/flex/XML.as
+++ b/frameworks/projects/XML/src/main/flex/XML.as
@@ -1062,17 +1062,23 @@ package
                                return p == "0";
                        var name:QName = toXMLName(p);
                        var i:int;
-                       for(i=0;i<_attributes.length;i++)
+                       if(name.isAttribute)
                        {
-                               if(_attributes[i].name().matches(name))
-                                       return true;
+                               for(i=0;i<_attributes.length;i++)
+                               {
+                                       if(_attributes[i].name().matches(name))
+                                               return true;
+                               }
                        }
-                       for(i=0;i<_children.length;i++)
+                       else
                        {
-                               if(_children[i].nodeKind() != "element")
-                                       continue;
-                               if(_children[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;
                }
@@ -2165,11 +2171,11 @@ package
                private function toAttributeName(name:*):QName
                {
                        var qname:QName;
-                       if(!name is QName)
+                       if(!(name is QName))
                        {
                                name = name.toString();
                                if(name.indexOf("@") > -1)
-                                       name = 
name.substring(name.indexOf("@"));
+                                       name = name.substring(name.indexOf("@") 
+ 1);
                        }
                        qname = toXMLName(name);
                        qname.isAttribute = true;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93c980dd/manualtests/XMLTest/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/manualtests/XMLTest/src/MyInitialView.mxml 
b/manualtests/XMLTest/src/MyInitialView.mxml
index efb4317..6b73d7f 100644
--- a/manualtests/XMLTest/src/MyInitialView.mxml
+++ b/manualtests/XMLTest/src/MyInitialView.mxml
@@ -97,6 +97,9 @@ limitations under the License.
         var list4:XMLList;
         var xml1:XML = <foo baz="true"/>;
         trace(xml1.toXMLString());
+        trace("should be true: " + xml1.hasOwnProperty("@baz"));
+        trace("should be false: " + xml1.hasOwnProperty("@foo"));
+        trace("should be false: " + xml1.hasOwnProperty("baz"));
         trace(xml1.toXMLString() == '<foo baz="true"/>');
         var baz:XMLList = xml1.@baz;
         trace("baz: " + xml1.@baz.toString() + " //true");

Reply via email to