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

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

commit 969353f3a345d84be4fe8c69776f21ac6ff380ea
Author: Alex Harui <aha...@apache.org>
AuthorDate: Mon Jan 7 22:30:36 2019 -0800

    fix up EventUtils now that compiler will catch passing a plain object in as 
an interface.  Use a factory function for Event and a conversion function for 
MouseEvent
---
 .../apache/royale/conversions/MouseEventInit.as    | 34 ++++++++++++++++++++++
 .../apache/royale/conversions/createEventInit.as   | 30 +++++++++++++++++++
 .../org/apache/royale/events/utils/EventUtils.as   | 18 ++++++++----
 3 files changed, 76 insertions(+), 6 deletions(-)

diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/conversions/MouseEventInit.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/conversions/MouseEventInit.as
new file mode 100644
index 0000000..f61154d
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/conversions/MouseEventInit.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.conversions
+{
+COMPILE::JS
+{
+    import window.MouseEventInit;
+}
+
+    /**
+     * @royaleignorecoercion window.MouseEventInit 
+     */
+    COMPILE::JS
+    public function MouseEventInit(value:Object):window.MouseEventInit
+    {
+        return value as window.MouseEventInit;
+    }
+}
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/conversions/createEventInit.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/conversions/createEventInit.as
new file mode 100644
index 0000000..1f37342
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/conversions/createEventInit.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.conversions
+{
+    /**
+     * @royaleignorecoercion EventModifierInit 
+     */
+    COMPILE::JS
+    public function createEventInit(bubbles:Boolean = false,
+                                    cancelable:Boolean = 
false):EventModifierInit
+    {
+        return { "bubbles": bubbles, "cancelable": cancelable } as 
EventModifierInit;
+    }
+}
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/EventUtils.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/EventUtils.as
index 42ee134..3ea56f0 100644
--- 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/EventUtils.as
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/utils/EventUtils.as
@@ -18,6 +18,14 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.events.utils
 {
+COMPILE::JS
+{
+    import org.apache.royale.conversions.createEventInit;
+    import org.apache.royale.conversions.MouseEventInit;
+    import window.Event;
+    import window.MouseEvent;
+}
+
     /**
         *  Provides static methods for creating custom events in JS
      *  
@@ -35,7 +43,7 @@ package org.apache.royale.events.utils
 
            try
            {
-               customEvent = new window.Event(type, {bubbles: bubbles, 
cancelable: cancelable});
+               customEvent = new window.Event(type, createEventInit(bubbles, 
cancelable));
                return customEvent;
            }
            catch (e:Error)
@@ -58,16 +66,14 @@ package org.apache.royale.events.utils
            var mouseEvent:Object = null;
 
            if (!params)
-           {
                params = {};
-           }
-
+           
            try
            {
                params.bubbles = bubbles;
                params.cancelable = cancelable;
-
-               mouseEvent = new window.MouseEvent(type, params);
+               var initObject:MouseEventInit = MouseEventInit(params);
+               mouseEvent = new window.MouseEvent(type, initObject);
                return mouseEvent;
            }
            catch (e:Error)

Reply via email to