SeaUrchinBot / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.ui.Container.prototype.addChildAt is wrong typed or misses type checks #489

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The addChildAt method at goog.ui.Container have a wrong typed parameter or 
parameter is used wrong.

The JSDoc comment defines that the parameter control is of type 
goog.ui.Component.

In the method body there are accessed goog.ui.Control-methods like 
'setDispatchTransitionEvents' which produces runtime errors when adding a 
goog.ui.Toolbar for example.

I wonder why the closure compiler isn't complaining about that.

Code snippet to reproduce the Problem:

    var container = new goog.ui.Container();
    var toolbar = new goog.ui.Toolbar();
    container.addChild( toolbar );

Thanks

Original issue reported on code.google.com by a...@gmx.net on 21 Aug 2012 at 2:53

GoogleCodeExporter commented 9 years ago
addChildAt is a method of Component, and has to support all Components. It 
would be incorrect for Container to accept less than that. This is how any 
language that supports subclassing works.

Closure Compiler's missing properties check is a "may be defined" check rather 
than a "must be defined" check. This is explained in more detail here
http://closuretools.blogspot.com/2011/01/property-by-any-other-name-part-3.html

Original comment by Nicholas.J.Santos on 21 Aug 2012 at 3:58