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
>

Reply via email to