This code in LzDataElement tries to classify an object arg, o, by looking at it's __proto__ field.
Do we have  protocol for finding object's class type that doesn't rely on __proto__ (which won't work
in IE 6 _javascript_, I believe)



LzDataElement.__LZv2E = function ( o ) {

    var type = typeof( o );
    type.toLowerCase();

    var c = [];
    if (type == "object") {
        var proto = o.__proto__;
        if ( proto == LzDataElement.prototype ||
             proto == LzDataNode.prototype ) {
            c[0] = o;
        } else if (proto == Date.prototype) {

            type = "date";
            // FIXME: [2004-04-10 pkang] what should we do with dates?

        } else if (proto == Array.prototype) {
            type = "array";
            var tag = (o.__LZtag != null ? o.__LZtag : 'item');
            for (var i=0; i < o.length; i++) {
                var tmpC = this.__LZv2E( o[i] );
                c[i] = new LzDataElement(tag, null, tmpC );
            }
        } else {
            type = "struct";
            var i = 0;
            for (var k in o) {
                // skip any properties that start with __LZ
                if (k.indexOf('__LZ') == 0) continue;
                c[i++] = new LzDataElement(k, null, this.__LZv2E(o[k]));
            }
        }
    } else if (o != null) {
        c[0] = new LzDataText( o );
    }

    if (c.length == 0) c = null;

    return c;
}

--
Henry Minsky
Software Architect
[EMAIL PROTECTED]

_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev

Reply via email to