[Laszlo-dev] Problems with the 'in' operator in swf9
Philip Romanik
promanik at laszlosystems.com
Tue Mar 11 12:36:31 PDT 2008
Hi Tucker,
Thanks for the explanation. We added a lot of 'in' tests for dhtml
and we will have remove them. I will try and make sure the base class
has a definition to make the problem go away. I might have a add a
few methods to LzMiniNode to handle some of the data tests.
Thanks!
Phil
>Um, probably behaving as expected. Non-public attributes are not
>enumerable, and `in` tests for enumerability. This is supposed to
>be a feature... we need to clean up our usage I think.
>
>So, depending on what you are really trying to do, there are a few
>approaches:
>
>1) Assuming this is the 'send-if-handles' idom, just make sure there
>is a default method for getExpectedAttribute in the base class so
>you can always call it, instead of testing for it's existence. Or,
>do an `is` test to see if this is of a class (or interface or mixin)
>that supports the protocol.
>
>2) If this is the 'get this attribute if it exists idiom' then I
>think we should change how we do that and not bother testing for the
>existence of the attribute first. You are allowed to reference non-
>existent attributes, you just need to silence our (and Flex's)
>warning by using ['attribute'] instead of .attribute. So, where we
>used to say:
>
> 'foo' in bar && bar.foo ...
>
>let's just say:
>
> bar['foo'] ...
>
>On 2008-03-11, at 15:16 EDT, Philip Romanik wrote:
>
> >
> > I am having problems with the 'in' operator in swf9. I ran a simple
> > test using an arbitrary method in LFCNode:
> >
> > var n1 = new LFCNode ();
> > trace ("test1: " + ('getExpectedAttribute' in n1)); trace ("test2: "
> > + ('getExpectedAttribute' in LFCNode));
> >
> > var n2 = new LzNode (null, null);
> > trace ("test3: " + ('getExpectedAttribute' in n2)); trace ("test4: "
> > + ('getExpectedAttribute' in LzNode));
> >
> >
> > When I run this I get 'false' for each test. However, if I insert the
> > word 'public' in front of 'getExpectedAttribute', I get
> >
> > test1: true
> > test2: false
> > test3: true
> > test4: false
> >
> > Shouldn't these tests produce 'true' in all cases?
> >
> >
> > Thanks!
> >
> > Phil
> >
> >
>
More information about the Laszlo-dev
mailing list