[Laszlo-dev] how do I check for the existence of an attribute?

Sarah Allen sarah at ultrasaurus.com
Mon Feb 9 18:17:42 PST 2009


The microphone has the following code:

             // Use duck typing to check for the existence of the
             // _setMic method, instead of checking if the
             // immediateparent is an instance of videoview, to avoid
             // loading the videoview class if it's not needed.
             if (immediateparent['_setMic']) {
                 immediateparent._setMic(this);
             }

This doesn't work because videoview no longer has a setMic method.   
Instead, we're supposed to use setAttribute...
However, then we would need to write:

             if (immediateparent['mic']) {
                 immediateparent.setAttribute('mic', this);
             }

except that won't work since mic is intialized to null and  
immediateparent['mic'] will evaluate to false.

Any syntax gurus in the house?

Thanks,
Sarah


More information about the Laszlo-dev mailing list