macklane / oryx-editor

Automatically exported from code.google.com/p/oryx-editor
Other
0 stars 0 forks source link

getChildById with deep=true incoherent [correction given] #474

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create your workflow
2. insert UIObjects, 
3. insert a UIObject in another UIObject. Let's call it a "sub element". 
4. in a JS console, call myUIObject.getChildById("ID_OF_YOUR_SUB_ELEMENT", 
true);  

What is the expected output?
The Javascript console sould print you the Sub Element.

What do you see instead?
The Javascript console prints you the Element that contains the sub element.

Please provide any additional information below.
You will find here the correction for this bug: 
https://gist.github.com/1029328

Original issue reported on code.google.com by florent....@gmail.com on 16 Jun 2011 at 2:31

GoogleCodeExporter commented 9 years ago
Note : the bug is due to the wrong use of Array.find.

By Calling Array.find, this will return the first elements which makes the 
function return true. Thus, if you return the result of the recursion in the 
function, you will obtain the element which have the result among its 
deep-children. But not the child ! 

Original comment by florent....@gmail.com on 16 Jun 2011 at 2:37