[Laszlo-checkins] r13837 - openlaszlo/trunk/WEB-INF/lps/lfc/core
ptw@openlaszlo.org
ptw at openlaszlo.org
Fri May 8 12:44:25 PDT 2009
Author: ptw
Date: 2009-05-08 12:44:23 -0700 (Fri, 08 May 2009)
New Revision: 13837
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
Log:
Change 20090508-ptw-G by ptw at dueling-banjos.home on 2009-05-08 10:52:53 EDT
in /Users/ptw/OpenLaszlo/trunk-2
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Ensure dynamic properties are created in instances
Bugs Fixed: LPP-8088 DHTML: many warnings from applyConstraintMethod() (partial)
Technical Reviewer: max (Message-ID: <4A048949.2060200 at laszlosystems.com>)
QA Reviewer: hminsky (pending)
Details:
Clean up the code in LzNode that makes sure dynamic properties
exist by using a cross-platform test: if accessing the dynamic
property returns undefined, make sure it exists in the instance by
setting it to undefined.
This does not fix the warning part of the bug, but it does make
swf9 work again.
Tests:
http://localhost:8080/4.2/test/extensions/html.lzx?lzr=swf9 No
longer gets a runtime error.
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs 2009-05-08 18:19:56 UTC (rev 13836)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs 2009-05-08 19:44:23 UTC (rev 13837)
@@ -230,10 +230,11 @@
this.addProperty(key, val);
} else if (val !== void 0) {
this[key] = val;
- } else if ($as3) {
- // not for ActionScript3
- } else if (! (key in this)) {
- this[key] = val;
+ } else if (this[key] === void 0) {
+ // Ensure dynamic properties exist (for `with(this)`),
+ // above test works in all runtimes to detect missing
+ // properties
+ this[key] = void 0;
}
delete iargs[key];
} else {
@@ -241,9 +242,10 @@
// have its initial value installed by the setter, but
// we need to create the attribute in the instance for
// implicit this to work correctly
- if ($as3) {
- // AS3 handles this at compile time
- } else if (! (key in this)) {
+ if (this[key] === void 0) {
+ // Ensure dynamic properties exist (for `with(this)`),
+ // above test works in all runtimes to detect missing
+ // properties
this[key] = void 0;
}
}
@@ -992,13 +994,13 @@
var inits = null;
var constraints = null;
- for ( var a in args ){
- var val = args[a];
- /* To see if it has a setter. Cf., setAttribute */
- var setr = '$lzc$set_' + a;
+ for ( var key in args ){
+ var val = args[key];
+ /* To see if it has key setter. Cf., setAttribute */
+ var setr = '$lzc$set_' + key;
//handle flash bug where objects slots are enumerated multiple times
- if ( oset[a] || args[a] === LzNode._ignoreAttribute ) continue;
- oset[ a ] = true;
+ if ( oset[key] || args[key] === LzNode._ignoreAttribute ) continue;
+ oset[ key ] = true;
if (val is LzInitExpr) {
// Ordering is important, constraint is a subclass of once
@@ -1023,40 +1025,42 @@
// implemented by a setter, so it never clobbers the
// method... er, unless you set the attribute to a
// function. YOW!
- if ($as3) {
- // AS3 handles this at compile time
- } else if (! (a in this)) {
- this[a] = void 0;
+ if (this[key] === void 0) {
+ // Ensure dynamic properties exist (for `with(this)`),
+ // above test works in all runtimes to detect missing
+ // properties
+ this[key] = void 0;
}
} else if (! this[setr]) {
// TODO: should already be declared, so we should just be
// able to set it, but that doesn't work if this is a
// method
if (val is Function) {
- this.addProperty(a, val);
+ this.addProperty(key, val);
} else if (val !== void 0) {
- this[a] = val;
- } else if ($as3) {
- // not for ActionScript3
- } else if (! (a in this)) {
- this[a] = val;
+ this[key] = val;
+ } else if (this[key] === void 0) {
+ // Ensure dynamic properties exist (for `with(this)`),
+ // above test works in all runtimes to detect missing
+ // properties
+ this[key] = void 0;
}
if (! constcall) {
//then we need to notify the rest of the system that this
//value changed.
- var evt = ("on" + a);
+ var evt = ("on" + key);
if (this[evt] is LzEvent) {
- if (this[evt].ready) this[ evt ].sendEvent( args[ a ] );
+ if (this[evt].ready) this[ evt ].sendEvent( args[ key ] );
}
}
} else if (this[setr] is Function) {
// TODO: simplify test above - can this[setr] ever not be a Function?
- if (a in this.earlySetters) {
+ if (key in this.earlySetters) {
if (hasearly == null) { hasearly = []; }
- hasearly[this.earlySetters[a]] = a;
+ hasearly[this.earlySetters[key]] = key;
} else {
if (hasset == null) { hasset = []; }
- hasset.push(a);
+ hasset.push(key);
}
}
}
@@ -1066,9 +1070,9 @@
if (i in hasearly) {
// bail if deleted, e.g. by setDatapath causing replication
if (this.__LZdeleted) return;
- var a = hasearly[i];
- var setr = '$lzc$set_' + a;
- this[setr]( args[a] );
+ var key = hasearly[i];
+ var setr = '$lzc$set_' + key;
+ this[setr]( args[key] );
}
}
}
@@ -1077,9 +1081,9 @@
for (var i = hasset.length - 1; i >= 0; i--) {
// bail if deleted, e.g. by setDatapath causing replication
if (this.__LZdeleted) return;
- var a = hasset[i];
- var setr = '$lzc$set_' + a;
- this[setr]( args[a] );
+ var key = hasset[i];
+ var setr = '$lzc$set_' + key;
+ this[setr]( args[key] );
}
}
More information about the Laszlo-checkins
mailing list