Yes, wrapping polyfills in beads seems like a good pattern.

-Alex

On 3/15/18, 2:43 AM, "Harbs" <[email protected]> wrote:

>Yup. :-)
>
>> On Mar 15, 2018, at 11:35 AM, Piotr Zarzycki
>><[email protected]> wrote:
>> 
>> Interesting this allows mimic other things probably if it's missing. :)
>> 
>> 2018-03-15 10:09 GMT+01:00 Harbs <[email protected]>:
>> 
>>> OK. I just pushed an IEEventAdapterBead which adds name getters to the
>>> event prototypes. It’ll just add it in IE. Along the way I added some
>>>new
>>> utility functions for creating getters.
>>> 
>>> I think this is lighter-weight, and I think it’s an interesting
>>>pattern.
>>> 
>>> Harbs
>>> 
>>>> On Mar 15, 2018, at 11:00 AM, Harbs <[email protected]> wrote:
>>>> 
>>>> Adding a different type of bead… ;-)
>>>> 
>>>>> On Mar 15, 2018, at 10:49 AM, Yishay Weiss <[email protected]>
>>> wrote:
>>>>> 
>>>>> Already merged mine, using a bead. Feel free to make changes if you
>>>>>see
>>> fit.
>>>>> 
>>>>> 
>>>>> 
>>>>> ________________________________
>>>>> From: Harbs <[email protected]>
>>>>> Sent: Thursday, March 15, 2018 10:40:34 AM
>>>>> To: [email protected]
>>>>> Subject: Re: [royale-asjs] branch EventConverter updated: Export
>>>>>cross
>>> browser support to a bead so core implementation stays efficient and
>>>works
>>> on non-IE browsers
>>>>> 
>>>>> I have what I think is a simpler (and more versatile) solution for
>>> these kinds of things.
>>>>> 
>>>>> I’m going to commit my idea soon.
>>>>> 
>>>>>> On Mar 15, 2018, at 10:37 AM, [email protected] wrote:
>>>>>> 
>>>>>> This is an automated email from the ASF dual-hosted git repository.
>>>>>> 
>>>>>> yishayw pushed a commit to branch EventConverter
>>>>>> in repository
>>>>>>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitb
>>>>>>ox.apache.org%2Frepos%2Fasf%2Froyale-asjs.git&data=02%7C01%7Caharui%4
>>>>>>0adobe.com%7Cafaeea1e5e664c1e373c08d58a593b29%7Cfa7b1b5a7b34438794aed
>>>>>>2c178decee1%7C0%7C0%7C636567038223923374&sdata=v2BdRqgbZl7SmNAn1%2BVb
>>>>>>8vg%2FP74oOF4fGCYE9niCkxs%3D&reserved=0
>>>>>> 
>>>>>> 
>>>>>> The following commit(s) were added to refs/heads/EventConverter by
>>> this push:
>>>>>>  new 429032f  Export cross browser support to a bead so core
>>> implementation stays efficient and works on non-IE browsers
>>>>>> 429032f is described below
>>>>>> 
>>>>>> commit 429032f75d4e48988980fda8e171c6c6e6b1e7bb
>>>>>> Author: DESKTOP-RH4S838\Yishay <[email protected]>
>>>>>> AuthorDate: Thu Mar 15 10:36:44 2018 +0200
>>>>>> 
>>>>>> Export cross browser support to a bead so core implementation stays
>>>>>> efficient and works on non-IE browsers
>>>>>> ---
>>>>>> .../Basic/src/main/resources/basic-manifest.xml    |  1 +
>>>>>> .../org/apache/royale/core/HTMLElementWrapper.as   | 23 +++---
>>>>>> .../beads/CrossBrowserFireListenerOverrideBead.as  | 93
>>> ++++++++++++++++++++++
>>>>>> 3 files changed, 106 insertions(+), 11 deletions(-)
>>>>>> 
>>>>>> diff --git 
>>>>>>a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>>> b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>>>>>> index a201ea1..dbff20e 100644
>>>>>> --- 
>>>>>>a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>>>>>> +++ 
>>>>>>b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>>>>>> @@ -87,6 +87,7 @@
>>>>>>  <component id="ListView" class="org.apache.royale.html.
>>> beads.ListView"/>
>>>>>>  <component id="AccordionView" class="org.apache.royale.html.
>>> beads.AccordionView"/>
>>>>>>  <component id="CenterElement" class="org.apache.royale.html.
>>> beads.CenterElement"/>
>>>>>> +    <component id="CrossBrowserFireListenerOverrideBead"
>>> 
>>>class="org.apache.royale.html.beads.CrossBrowserFireListenerOverrideBead
>>>"
>>> />
>>>>>>  <component id="AccessibilityAltBead"
>>>>>>class="org.apache.royale.html.beads.AccessibilityAltBead"
>>> />
>>>>>>  <component id="DataGridColumnChangePropagator"
>>> class="org.apache.royale.html.beads.DataGridColumnChangePropagator" />
>>>>>>  <component id="DataGridColumnForceChangePropagator"
>>> 
>>>class="org.apache.royale.html.beads.DataGridColumnForceChangePropagator"
>>> />
>>>>>> diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/
>>> royale/core/HTMLElementWrapper.as b/frameworks/projects/Basic/
>>> src/main/royale/org/apache/royale/core/HTMLElementWrapper.as
>>>>>> index 7aa8a0b..7228fbc 100644
>>>>>> --- a/frameworks/projects/Basic/src/main/royale/org/apache/
>>> royale/core/HTMLElementWrapper.as
>>>>>> +++ b/frameworks/projects/Basic/src/main/royale/org/apache/
>>> royale/core/HTMLElementWrapper.as
>>>>>> @@ -71,17 +71,18 @@ package org.apache.royale.core
>>>>>>             {
>>>>>>          var e:IBrowserEvent;
>>>>>>          var nativeEvent:Object = eventObject.getBrowserEvent();
>>>>>> -                     var constructorName:String =
>>> nativeEvent.constructor.toString();
>>>>>> -                     if (constructorName.indexOf('KeyboardEvent') >
>>> -1)
>>>>>> -                     {
>>>>>> -                             e = KeyboardEventConverter.
>>> convert(nativeEvent);
>>>>>> -                     } else if
>>>>>>(constructorName.indexOf('MouseEvent')
>>>> -1)
>>>>>> -                     {
>>>>>> -                             e = MouseEventConverter.convert(
>>> nativeEvent);
>>>>>> -                     } else
>>>>>> -                     {
>>>>>> -                             e = new org.apache.royale.events.
>>> BrowserEvent();
>>>>>> -                     }
>>>>>> +            switch(nativeEvent.constructor.name)
>>>>>> +            {
>>>>>> +                case "KeyboardEvent":
>>>>>> +                    e =
>>>>>>KeyboardEventConverter.convert(nativeEvent);
>>>>>> +                    break;
>>>>>> +                case "MouseEvent":
>>>>>> +                    e = MouseEventConverter.convert(nativeEvent);
>>>>>> +                    break;
>>>>>> +                default:
>>>>>> +                    e = new
>>>>>>org.apache.royale.events.BrowserEvent();
>>>>>> +                    break;
>>>>>> +            }
>>>>>> 
>>>>>>                     e.wrapEvent(eventObject);
>>>>>>                     return
>>>>>>HTMLElementWrapper.googFireListener(listener,
>>> e);
>>>>>> diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/
>>> royale/html/beads/CrossBrowserFireListenerOverrideBead.as
>>> 
>>>b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads
>>>/
>>> CrossBrowserFireListenerOverrideBead.as
>>>>>> new file mode 100644
>>>>>> index 0000000..06de46f
>>>>>> --- /dev/null
>>>>>> +++ b/frameworks/projects/Basic/src/main/royale/org/apache/
>>> royale/html/beads/CrossBrowserFireListenerOverrideBead.as
>>>>>> @@ -0,0 +1,93 @@
>>>>>> +///////////////////////////////////////////////////////////
>>> /////////////////////
>>>>>> +//
>>>>>> +//  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
>>>>>> +//
>>>>>> +//      
>>>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.a
>>>>>>pache.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caharui%40adobe.com%
>>>>>>7Cafaeea1e5e664c1e373c08d58a593b29%7Cfa7b1b5a7b34438794aed2c178decee1
>>>>>>%7C0%7C0%7C636567038223923374&sdata=SPt6oA3EYstrxVT8PNWbo51swGoOeW319
>>>>>>ph5HL90pEc%3D&reserved=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;
>>>>>> +     import org.apache.royale.core.HTMLElementWrapper;
>>>>>> +    COMPILE::JS
>>>>>> +     {
>>>>>> +        import goog.events;
>>>>>> +        import goog.events.EventTarget;
>>>>>> +        import goog.events.BrowserEvent;
>>>>>> +        import org.apache.royale.events.IBrowserEvent;
>>>>>> +        import
>>>>>>org.apache.royale.events.utils.KeyboardEventConverter;
>>>>>> +        import org.apache.royale.events.utils.MouseEventConverter;
>>>>>> +     }
>>>>>> +    /**
>>>>>> +     *  Overrides default HTMLElementWrapper implementation to make
>>> sure events are converted on all browsers
>>>>>> +      *  including IE.
>>>>>> +     *  @langversion 3.0
>>>>>> +     *  @playerversion Flash 10.2
>>>>>> +     *  @playerversion AIR 2.6
>>>>>> +     *  @productversion Royale 0.92
>>>>>> +     */
>>>>>> +     public class CrossBrowserFireListenerOverrideBead implements
>>> IBead
>>>>>> +     {
>>>>>> +        /**
>>>>>> +         *  Constructor.
>>>>>> +         *
>>>>>> +         *  @langversion 3.0
>>>>>> +         *  @playerversion Flash 10.2
>>>>>> +         *  @playerversion AIR 2.6
>>>>>> +         *  @productversion Royale 0.92
>>>>>> +         */
>>>>>> +             public function CrossBrowserFireListenerOverrideBead()
>>>>>> +             {
>>>>>> +                     super();
>>>>>> +             }
>>>>>> +
>>>>>> +        /**
>>>>>> +         *  @copy org.apache.royale.core.IBead#strand
>>>>>> +         *
>>>>>> +         *  @langversion 3.0
>>>>>> +         *  @playerversion Flash 10.2
>>>>>> +         *  @playerversion AIR 2.6
>>>>>> +         *  @productversion Royale 0.92
>>>>>> +         */
>>>>>> +        public function set strand(value:IStrand):void
>>>>>> +        {
>>>>>> +                     COMPILE::JS
>>>>>> +                     {
>>>>>> +                             goog.events.fireListener =
>>> CrossBrowserFireListenerOverrideBead.fireListenerOverride;
>>>>>> +                     }
>>>>>> +        }
>>>>>> +
>>>>>> +             COMPILE::JS
>>>>>> +             static protected function
>>>>>>fireListenerOverride(listener:Object,
>>> eventObject:goog.events.BrowserEvent):Boolean
>>>>>> +             {
>>>>>> +            var e:IBrowserEvent;
>>>>>> +            var nativeEvent:Object = eventObject.getBrowserEvent();
>>>>>> +                     var constructorName:String =
>>> nativeEvent.constructor.toString();
>>>>>> +                     if (constructorName.indexOf('KeyboardEvent') >
>>> -1)
>>>>>> +                     {
>>>>>> +                             e = KeyboardEventConverter.
>>> convert(nativeEvent);
>>>>>> +                     } else if
>>>>>>(constructorName.indexOf('MouseEvent')
>>>> -1)
>>>>>> +                     {
>>>>>> +                             e = MouseEventConverter.convert(
>>> nativeEvent);
>>>>>> +                     } else
>>>>>> +                     {
>>>>>> +                             e = new org.apache.royale.events.
>>> BrowserEvent();
>>>>>> +                     }
>>>>>> +
>>>>>> +                     e.wrapEvent(eventObject);
>>>>>> +                     return
>>>>>>HTMLElementWrapper.googFireListener(listener,
>>> e);
>>>>>> +             }
>>>>>> +    }
>>>>>> +}
>>>>>> 
>>>>>> --
>>>>>> To stop receiving notification emails like this one, please contact
>>>>>> [email protected].
>>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
>> -- 
>> 
>> Piotr Zarzycki
>> 
>> Patreon: 
>>*https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.pat
>>reon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7Cafaeea1e5e66
>>4c1e373c08d58a593b29%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365670
>>38223933384&sdata=Lnijt3WwCHHi%2BT7Q8znvg6A4%2BPsic4zbOhaB58HB5N0%3D&rese
>>rved=0
>> 
>><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.pat
>>reon.com%2Fpiotrzarzycki&data=02%7C01%7Caharui%40adobe.com%7Cafaeea1e5e66
>>4c1e373c08d58a593b29%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365670
>>38223933384&sdata=Lnijt3WwCHHi%2BT7Q8znvg6A4%2BPsic4zbOhaB58HB5N0%3D&rese
>>rved=0>*
>

Reply via email to