Hi Josh,

many thanks, your workaround works, but it's a shame that "hasOwnProperty"
can't be used and does not be reliable :(

Thanks!

:)



2017-01-07 17:28 GMT+01:00 Josh Tynjala <joshtynj...@gmail.com>:

> Are you testing a release build? Remember that Closure compiler renames
> member variables, so using a string to check if they exist won't work.
>
> It can be frustrating, I know. To this day, I still wish that this drastic
> renaming with Closure hadn't been the default we chose. It breaks a number
> of common things like this.
>
> You may be able to do something like this instead, I think:
>
> If(value.label !== undefined)
>
> JavaScript generally won't throw an error when you try to access a property
> that doesn't exist because all JS objects are dynamic by default.
>
> - Josh
>
> On Jan 7, 2017 5:02 AM, "Carlos Rovira" <carlosrov...@apache.org> wrote:
>
> > Hi,
> >
> > I have this code in a Item Renderer:
> >
> > override public function set data(value:Object):void
> > {
> > super.data = value;
> >
> > if(value == null) return;
> >
> > /*if(value.hasOwnProperty('label')) {
> >                 label = String(value.label);
> > } else {
> > label = String(value);
> > }*/
> > label = String(value.label);
> >
> >             /*if(value.hasOwnProperty('href')) {
> >                 href = String(value.href);
> > }*/
> >             href = String(value.href);
> >
> > COMPILE::JS
> > {
> > if(textNode != null)
> > {
> > textNode.nodeValue = label;
> > }
> > }
> > }
> >
> > The commented code is not working. So I committed the line just below to
> > get it working for now.
> >
> > I'm passing typed object in the dataProvider :
> >
> > package vos
> > {
> >     public class NavigationLinkVO
> >     {
> >         [Bindable]
> >         public var label:String;
> >         [Bindable]
> >         public var href:String;
> >
> >         public function NavigationLinkVO(label:String, href:String)
> >         {
> >             this.label = label;
> >             this.href = href;
> >         }
> >     }
> > }
> >
> > And the dataProvider is:
> >
> > private var _mainNavigation:Array = [
> >                 new NavigationLinkVO("About", "
> > https://getmdl.io/index.html
> > "),
> >                 new NavigationLinkVO("Getting Started", "
> > https://getmdl.io/started/index.html";),
> >                 new NavigationLinkVO("Components", "
> > https://getmdl.io/components/index.html";),
> >                 new NavigationLinkVO("Customize", "
> > https://getmdl.io/customize/index.html";)
> >         ];
> >
> > So, "label" and "href" are properties in the object, so why
> > "hasOwnProperty" is not working? is a bug?
> >
> > Thanks
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>



-- 

Carlos Rovira
Director General
M: +34 607 22 60 05
http://www.codeoscopic.com
http://www.avant2.es

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si ha recibido este mensaje por
error, le rogamos que nos lo comunique inmediatamente por esta misma vía y
proceda a su destrucción.

De la vigente Ley Orgánica de Protección de Datos (15/1999), le comunicamos
que sus datos forman parte de un fichero cuyo responsable es CODEOSCOPIC
S.A. La finalidad de dicho tratamiento es facilitar la prestación del
servicio o información solicitados, teniendo usted derecho de acceso,
rectificación, cancelación y oposición de sus datos dirigiéndose a nuestras
oficinas c/ Paseo de la Habana 9-11, 28036, Madrid con la documentación
necesaria.

Reply via email to