estanglerbm opened a new pull request #1027:
URL: https://github.com/apache/royale-asjs/pull/1027


   Remove @royaleignorecoercion from several UIComponent methods (which 
affected "return" statements), because they allowed non-IUIComponent objects to 
be returned (in JS) when the method declaration promised an IUIComponent 
object.  Also add code to easily detect non-IUIComponent child objects during 
get measuredWidth() / measuredHeight() in JS.
   
   (I was originally going to submit with a temporary workaround by doing a 
typeof(child.getExplicitOrMeasuredHeight) != "function" in measuredHeight(), 
for example, to detect non-IUIComponent objects.  But PR #1026 was merged, so I 
changed this to the real fixes.)
   
   Several UIComponent methods, like getChildAt(), would return non-null values 
that did not actually implement IUIComponent, even though the return value for 
the methods promised that.  There are multiple ways to handle that, but at the 
end of the day, it's really really bad for a typed language to allow this 
(without a really good reason).  The only reason was performance, but that 
should be much better now.
   
   Several people have reported (and several maintainers have correctly 
diagnosed) an error similar to the following:
   
   ```
   Uncaught TypeError: child.getExplicitOrMeasuredHeight is not a function
       get__measuredHeight .../mx/core/UIComponent.js:3091
       getExplicitOrMeasuredHeight .../mx/core/UIComponent.js:1432
       getPreferredUBoundsHeight .../mx/core/LayoutElementUIComponentUtils.js:72
       getPreferredBoundsHeight .../mx/core/LayoutElementUIComponentUtils.js:166
       getPreferredBoundsHeight .../mx/core/UIComponent.js:1950
       spark_layouts_VerticalLayout_getElementHeight 
.../spark/layouts/VerticalLayout.js:556
   ```
   
   The error is caused by UIComponent.getChildAt() returning an object that 
does not actually implement IUIComponent.  This typically happens because an 
emulation class derived from a non-MX / non-Spark class doesn't implement 
IUIComponent.
   
   Essentially the same issue was reported in #789 and #983.
   
   With the changes in this PR, the following are some of the 
classes--identified by the new trace() code--that don't implement IUIComponent:
   
   ```
   Child class not IUIComponent: 
mx.controls.advancedDataGridClasses.AdvancedDataGridButtonBar
   Child class not IUIComponent: 
mx.controls.advancedDataGridClasses.AdvancedDataGridListArea
   ```
   
   And sure enough, they are thin wrappers on non-MX classes, with no 
implementation of IUIComponent.
   
   [Aside:  I don't know the best way to implement getExplicitOrMeasuredWidth() 
/ getExplicitOrMeasuredHeight() for these classes, off-hand.  (Explicit 
width/height is there, but don't know the measured values.)  I don't know how 
much work is needed for the other IUIComponent pieces.]
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to