Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

piotrz
Guys,

If anyone is seeing some problems with this let me know. When I started to
use numElements without those fix it didn't work.

Piotr

2017-02-09 12:34 GMT+01:00 <[hidden email]>:

> Repository: flex-asjs
> Updated Branches:
>   refs/heads/develop d40b9ddff -> 9855fa49d
>
>
> - Fix not working numElements
> - Fix failing internalChildren function when element is undefined
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/5ea3f1b3
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/5ea3f1b3
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/5ea3f1b3
>
> Branch: refs/heads/develop
> Commit: 5ea3f1b3230ae20fde48202eca23e641dd137861
> Parents: d40b9dd
> Author: piotrz <[hidden email]>
> Authored: Thu Feb 9 12:32:45 2017 +0100
> Committer: piotrz <[hidden email]>
> Committed: Thu Feb 9 12:32:45 2017 +0100
>
> ----------------------------------------------------------------------
>  .../HTML/src/main/flex/org/apache/flex/core/ContainerBase.as       | 2 +-
>  .../projects/HTML/src/main/flex/org/apache/flex/core/UIBase.as     | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 5ea3f1b3/frameworks/projects/HTML/src/main/flex/org/apache/
> flex/core/ContainerBase.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/core/ContainerBase.as
> b/frameworks/projects/HTML/src/main/flex/org/apache/flex/
> core/ContainerBase.as
> index 047b635..e150ac1 100644
> --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/
> core/ContainerBase.as
> +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/
> core/ContainerBase.as
> @@ -231,7 +231,7 @@ package org.apache.flex.core
>                  */
>                 public function $numElements():int
>                 {
> -                       return super.numElements();
> +                       return super.numElements;
>                 }
>
>                 /**
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 5ea3f1b3/frameworks/projects/HTML/src/main/flex/org/apache/
> flex/core/UIBase.as
> ----------------------------------------------------------------------
> 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 b075e72..d9804b2 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
> @@ -799,6 +799,8 @@ package org.apache.flex.core
>          COMPILE::JS
>          public function internalChildren():Array
>          {
> +            if (!element) return [];
> +
>              return element.childNodes as Array;
>          }
>
>
>


--

Greetings
Piotr Zarzycki

Flex/AIR/.NET Developer

mobile: +48 880 859 557
e-mail: [hidden email]
skype: zarzycki10

LinkedIn: http://www.linkedin.com/piotrzarzycki
<https://pl.linkedin.com/in/piotr-zarzycki-92a53552>
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

Alex Harui


On 2/9/17, 3:36 AM, "Piotr Zarzycki" <[hidden email]> wrote:

>Guys,
>
>If anyone is seeing some problems with this let me know. When I started to
>use numElements without those fix it didn't work.
>
>>@@ -231,7 +231,7 @@ package org.apache.flex.core
>>                  */
>>                 public function $numElements():int
>>                 {
>> -                       return super.numElements();
>> +                       return super.numElements;
>>                 }

Hmm.  I thought the Compiler knew to report an error there.  Oh well, good
catch.

>> @@ -799,6 +799,8 @@ package org.apache.flex.core
>>          COMPILE::JS
>>          public function internalChildren():Array
>>          {
>> +            if (!element) return [];
>> +
>>              return element.childNodes as Array;
>>          }
>>

I would be interested to know why internalChildren got called without an
element.  Elements get created pretty early.

-Alex

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

piotrz
Hi Alex,

I think the reason that we haven't had problems with numElements is that no one use it before. It's true that compiler should catch it even without using, but it didn't.

As for the internalChildren - Sankar in his application did find one scenario with Tabs component where our element was undefined.

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

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

Alex Harui


On 2/9/17, 8:38 AM, "piotrz" <[hidden email]> wrote:

>Hi Alex,
>
>I think the reason that we haven't had problems with numElements is that
>no
>one use it before. It's true that compiler should catch it even without
>using, but it didn't.
>
>As for the internalChildren - Sankar in his application did find one
>scenario with Tabs component where our element was undefined.

Do you have time to figure out why element is undefined?  Adding defensive
code doesn't scale.  Eventually it adds up to something.  So if 99% of the
time the defensive code doesn't do anything we want to understand what it
would take to make it 100% so we can remove that code.

Thanks,
-Alex

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

piotrz
Yes I will take a look into that deeply.

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

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

yishayw
In reply to this post by piotrz
numElements works for me. The problem you found was with $numElements. I think we haven't seen a bug thus far because ContainerBase.$numElements just calls super.numElements which returns the number of elements in UIBase. Usually (always?) there's one component there, which is the internal contentView. ContainerBase.numElements, on the other hand, returns the number of elements in the contentView itself.

In short, $numElements in all scenarios I'm aware of is 1. I suppose a defined function implicitly cast to an int will return 1 as well (haven't tried it).

BTW, I see the same problem in ContainerBaseStrandChildren.$numElements and in ListBaseStrandChildren.$numElements.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

piotrz
Yishay,

In my scenario I have content where numElements is greater than 1. [1]. I'm using it to check whether I have any children apart of TabBar - it means to me that TabBar contains also TabPanel-s (content holder for each TabButton).

If numElements is failing as it's in my case in other layouts it probably should be fixed, but I won't touch it till someone will not show me cases when it's failing.

[1] https://github.com/apache/flex-asjs/blob/develop/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/TabsView.as

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

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

Alex Harui
In reply to this post by Alex Harui
Hi Piotr,

Did we ever figure out how internalChildren got called so early that
element was undefined?

-Alex

On 2/9/17, 10:56 AM, "Alex Harui" <[hidden email]> wrote:

>
>
>On 2/9/17, 8:38 AM, "piotrz" <[hidden email]> wrote:
>
>>Hi Alex,
>>
>>I think the reason that we haven't had problems with numElements is that
>>no
>>one use it before. It's true that compiler should catch it even without
>>using, but it didn't.
>>
>>As for the internalChildren - Sankar in his application did find one
>>scenario with Tabs component where our element was undefined.
>
>Do you have time to figure out why element is undefined?  Adding defensive
>code doesn't scale.  Eventually it adds up to something.  So if 99% of the
>time the defensive code doesn't do anything we want to understand what it
>would take to make it 100% so we can remove that code.
>
>Thanks,
>-Alex
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

piotrz
Alex,

Well I have to admit that I didn't find reason. Not sure if I found the time to dig into that. I can create some example which allows me reproduce it if my memory back on this one.

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

Re: [1/2] git commit: [flex-asjs] [refs/heads/develop] - - Fix not working numElements - Fix failing internalChildren function when element is undefined

Alex Harui
Let's wait a fees days to see if Santanu will see this and can provide the
test case.  Or at least, the stack trace.

-Alex

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

>Alex,
>
>Well I have to admit that I didn't find reason. Not sure if I found the
>time
>to dig into that. I can create some example which allows me reproduce it
>if
>my memory back on this one.
>
>Piotr
>
>
>
>-----
>Apache Flex PMC
>[hidden email]
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FRe-1-2-git-commit-flex-asjs-refs-hea
>ds-develop-Fix-not-working-numElements-Fix-failing-internalChildd-tp59183p
>61178.html&data=02%7C01%7C%7C9d85beeddd1a476f971b08d486298982%7Cfa7b1b5a7b
>34438794aed2c178decee1%7C0%7C0%7C636280960340264359&sdata=3fsuaXPUtT1A8v72
>Xak%2FS%2BQfk89aBx63o7UMrUeuTaY%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Loading...