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

harbs 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 af19f12  Added utility function for adding JS getters
af19f12 is described below

commit af19f12fb623a473e16a4d83e0d89234abdaea4d
Author: Harbs <[email protected]>
AuthorDate: Thu Mar 15 11:06:51 2018 +0200

    Added utility function for adding JS getters
    
    Added IEEventAdapterBead which adds required name getters for MouseEvent 
and KeyboardEvent protoypes.
---
 .../Basic/src/main/resources/basic-manifest.xml    |  1 +
 .../apache/royale/html/beads/IEEventAdapterBead.as | 66 ++++++++++++++++++++++
 .../projects/Core/src/main/royale/CoreClasses.as   |  2 +
 .../org/apache/royale/utils/object/defineGetter.as | 34 +++++++++++
 .../royale/utils/object/defineSimpleGetter.as      | 38 +++++++++++++
 5 files changed, 141 insertions(+)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index dbff20e..442fc49 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -96,6 +96,7 @@
 
     <component id="ApplicationParameters" 
class="org.apache.royale.html.beads.ApplicationParametersBead"/>
     <component id="ApplicationParametersCaseInsensitive" 
class="org.apache.royale.html.beads.ApplicationParametersCaseInsensitiveBead"/>
+    <component id="IEEventAdapter" 
class="org.apache.royale.html.beads.IEEventAdapterBead"/>
 
     <component id="SimpleAlert" class="org.apache.royale.html.SimpleAlert"/>
     <component id="Alert" class="org.apache.royale.html.Alert"/>
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/IEEventAdapterBead.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/IEEventAdapterBead.as
new file mode 100644
index 0000000..41711a6
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/IEEventAdapterBead.as
@@ -0,0 +1,66 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 "Licens"); 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.html.beads
+{
+    import org.apache.royale.core.IBead;
+    import org.apache.royale.core.IStrand;
+       COMPILE::JS
+       {
+               import org.apache.royale.utils.object.defineSimpleGetter;
+       }
+
+       /**
+        *  The IEEventAdapterBead is used to get URL parameter values specified
+     *  when loading an application. It's different than the 
ApplicationParametersBead
+     *  in that URL parameter keys are case insensitive.
+        * 
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9.2
+        */
+    public class IEEventAdapterBead implements IBead
+    {
+        public function IEEventAdapterBead()
+        {
+            
+        }
+
+               /**
+                *  @copy org.apache.royale.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.3
+                */
+               public function set strand(value:IStrand):void
+               {
+                       COMPILE::JS
+                       {
+                               if(typeof 
window["KeyboardEvent"].prototype["name"] == "undefined")
+                               {// IE does not have a prototype name property
+                                       
defineSimpleGetter(window["KeyboardEvent"].prototype,"name","KeyboardEvent");
+                                       
defineSimpleGetter(window["MouseEvent"].prototype,"name","MouseEvent");
+                               }
+                       }
+               }
+
+    }
+}
\ No newline at end of file
diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as 
b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index f29e2e5..8685789 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -222,6 +222,8 @@ internal class CoreClasses
        {
                import org.apache.royale.core.WrappedHTMLElement 
;WrappedHTMLElement;
            import org.apache.royale.core.IRoyaleElement; IRoyaleElement;
+               import org.apache.royale.utils.object.defineGetter; 
defineGetter;
+               import org.apache.royale.utils.object.defineSimpleGetter; 
defineSimpleGetter;
        }
        //Package Level Functions
        import org.apache.royale.debugging.assert; assert;
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/defineGetter.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/defineGetter.as
new file mode 100644
index 0000000..501cd14
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/defineGetter.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils.object
+{
+       /**
+        *  Defines a getter function on a Javascript object (often used to add 
to prototypes)
+     *  Takes a function which returns a value
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9.3
+        */
+    public function 
defineGetter(obj:Object,prop:String,getterFunction:Function):void
+    {
+            Object.defineProperty(obj, prop, {"get": getterFunction});
+        }
+    
+}
\ No newline at end of file
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/defineSimpleGetter.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/defineSimpleGetter.as
new file mode 100644
index 0000000..42b5d9f
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/defineSimpleGetter.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.utils.object
+{
+       /**
+        *  Defines a getter function on a Javascript object (often used to add 
to prototypes)
+     *  Takes a simple value to return.
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9.3
+        */
+    public function defineSimpleGetter(obj:Object,prop:String,returnVal:*):void
+    {
+            Object.defineProperty(obj, prop, {
+                "get": function ():* {
+                    return returnVal;
+                }
+            });
+        }
+    
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to