You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/04/02 10:29:25 UTC

[royale-asjs] branch develop updated: forgot a new file in XML lib

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new b11b946  forgot a new file in XML lib
b11b946 is described below

commit b11b946952c59a11ded7ddb22755dc56cc07ea27
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu Apr 2 23:28:55 2020 +1300

    forgot a new file in XML lib
---
 .../org/apache/royale/language/toAttributeName.as  | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/frameworks/projects/XML/src/main/royale/org/apache/royale/language/toAttributeName.as b/frameworks/projects/XML/src/main/royale/org/apache/royale/language/toAttributeName.as
new file mode 100644
index 0000000..416940b
--- /dev/null
+++ b/frameworks/projects/XML/src/main/royale/org/apache/royale/language/toAttributeName.as
@@ -0,0 +1,55 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.language
+{
+
+   
+    COMPILE::JS
+     /**
+     *
+     * @royaleignorecoercion QName
+     * @royalesuppressexport
+     */
+    [Exclude]
+    public function toAttributeName(name:*):QName
+    {
+        const typeName:String = typeof name;
+        if (name == null || typeName == 'number'|| typeName == 'boolean') {
+            throw new TypeError('invalid xml name');
+        }
+
+        var qname:QName;
+        //@todo: typeName == 'object' && ... className=='QName' etc here (avoid Language.is)
+        if (name is QName) {
+            if (QName(name).isAttribute) qname = name as QName;
+            else {
+                qname = new QName(name);
+                qname.setIsAttribute(true);
+            }
+        } else {
+            var str:String = name.toString();
+            //normalize
+            var idx:int = str.indexOf('@');
+            if (idx != -1) str = str.slice(idx+1);
+            qname = new QName(str);
+            qname.setIsAttribute(true);
+        }
+        return qname;
+    }
+}