Re: git commit: [flex-asjs] [refs/heads/feature/chart-work] - Method getElementAt should return null if element not exists on JS sight

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/feature/chart-work] - Method getElementAt should return null if element not exists on JS sight

Alex Harui
Hi Piotr,

I'm wondering why some other code called getElementAt with an invalid
index.  Do we really need defensive code like this?

Thanks,
-Alex

On 4/2/17, 1:54 PM, "[hidden email]" <[hidden email]> wrote:

>Repository: flex-asjs
>Updated Branches:
>  refs/heads/feature/chart-work de48d638e -> 3d92c1c3a
>
>
>Method getElementAt should return null if element not exists on JS sight
>
>
>Project:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Frepo&data=02%7C01%7C%7Cfc958bcc743
>74f70c62908d47a0a81a6%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6362676
>32925352663&sdata=FgOBYzB84GNwYjkWLfiPSD%2BqaNm5%2F88apiCeRfspZXg%3D&reser
>ved=0
>Commit:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fcommit%2F3d92c1c3&data=02%7C01%7C%
>7Cfc958bcc74374f70c62908d47a0a81a6%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%
>7C0%7C636267632925352663&sdata=tuMQ8oYjITRbU8IyzWziiyeAtEE6vVL%2BFPU3Ss44V
>S8%3D&reserved=0
>Tree:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Ftree%2F3d92c1c3&data=02%7C01%7C%7C
>fc958bcc74374f70c62908d47a0a81a6%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C
>0%7C636267632925352663&sdata=acLn0k3uWpk1mkvNdMx1JAWegpED2Aavi7ThgCGIrQk%3
>D&reserved=0
>Diff:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fdiff%2F3d92c1c3&data=02%7C01%7C%7C
>fc958bcc74374f70c62908d47a0a81a6%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C
>0%7C636267632925352663&sdata=E9vx%2FXFguS2mVzIm98MHBjKQLgTJ0Om61qiaG8C10%2
>FI%3D&reserved=0
>
>Branch: refs/heads/feature/chart-work
>Commit: 3d92c1c3a79f5a334d008f1b54d3b53048a93465
>Parents: de48d63
>Author: piotrz <[hidden email]>
>Authored: Sun Apr 2 22:54:45 2017 +0200
>Committer: piotrz <[hidden email]>
>Committed: Sun Apr 2 22:54:45 2017 +0200
>
>----------------------------------------------------------------------
> .../projects/HTML/src/main/flex/org/apache/flex/core/UIBase.as  | 5 +++++
> 1 file changed, 5 insertions(+)
>----------------------------------------------------------------------
>
>
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F3d92c1c3%2Fframeworks%2Fpro
>jects%2FHTML%2Fsrc%2Fmain%2Fflex%2Forg%2Fapache%2Fflex%2Fcore%2FUIBase.as&
>data=02%7C01%7C%7Cfc958bcc74374f70c62908d47a0a81a6%7Cfa7b1b5a7b34438794aed
>2c178decee1%7C0%7C0%7C636267632925352663&sdata=oFj070ssakLLA%2FySQo0DSHQEi
>%2B3gXO%2BM5XEsJk%2BTsc4%3D&reserved=0
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/HTML/src/main/flex/org/apache/flex/core/UIBase.as
>b/frameworks/projects/HTML/src/main/flex/org/apache/flex/core/UIBase.as
>index af9e255..ad4f999 100644
>---
>a/frameworks/projects/HTML/src/main/flex/org/apache/flex/core/UIBase.as
>+++
>b/frameworks/projects/HTML/src/main/flex/org/apache/flex/core/UIBase.as
>@@ -1087,6 +1087,11 @@ package org.apache.flex.core
>             COMPILE::JS
>             {
>                 var children:Array = internalChildren();
>+                if (children.length == 0)
>+                {
>+                    return null;
>+                }
>+
>                 return children[index].flexjs_wrapper;
>             }
>         }        
>

Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/feature/chart-work] - Method getElementAt should return null if element not exists on JS sight

piotrz
Hi Alex,

I think I went in the scenario in MDL where children array do not contains anything. It was related to Tabs, but I don't remember correctly. Similar code is for SWF version in case where _element is null.

Do you want me to remove it ?

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: git commit: [flex-asjs] [refs/heads/feature/chart-work] - Method getElementAt should return null if element not exists on JS sight

Alex Harui


On 4/17/17, 11:47 PM, "piotrz" <[hidden email]> wrote:

>Hi Alex,
>
>I think I went in the scenario in MDL where children array do not contains
>anything. It was related to Tabs, but I don't remember correctly. Similar
>code is for SWF version in case where _element is null.
>
>Do you want me to remove it ?

Try removing it and see what breaks.  In general, we don't want to add
defensive code in the production code (we could start creating other
versions of code that does have helpful code for development time).
Hopefully, by the time you go to production, you've added the checks in
your application code to make sure that the index passed to getElementAt
is valid.

Thanks,
-Alex