From: Robert R. <rai...@us...> - 2000-10-29 00:05:17
|
I added a hasChildren method to the dynlayer and dyndocument to make it easier to check for children, since there are two different states that the children array can have that mean there are no children. DynLayer.prototype.hasChildren=function() { return !this.children||!this.children.length?false:true } DynDocument.prototype.hasChildren=function() { return !this.children||!this.children.length?false:true } Later, Robert <rai...@us...> > Yes, a boolean could do the same trick. Maybe removeChild/deleteChild can > set it to true/false if the length becomes zero. > > My point is that when you define an object's prototype structure with > another object, as in WidgetX, all of the properties of that base DynLayer > instance are shared with each Widget. > > Widget.prototype=new DynLayer() <-- Widget.prototype is a new DynLayer > *instance* > > This is generally okay in DynAPI2 because the shared properties are > eventually overwritten with unique ones. > > For example, all WidgetX model widgets share the *same* css, elm and doc > object when first constructed. But when you add them to a parent object, > the assignElement method overwrites them with *unique* values. > > But children[] is never overwritten anywhere, so it remains a reference to > the children array of the shared base DynLayer instance. So we either have > to 1) always remember to assign it "manually" in our widget code, or 2) find > a better place in the DynLayer code to assign it to ensure it is unique. > > I'm not trying to undermine the WidgetX model, because it's an easy way to > achieve a sort of inheritance, but this issue needs to be addressed. Who > knows what kind of memory leaks this may cause in the long run: > > Widget1.prototype = new DynLayer(); > Widget2.prototype = new Widget1(); > Widget3.prototype = new Widget2(); etc. > > scottandrew > > > > -----Original Message----- > From: Robert Rainwater <rai...@us...> > To: Scott Andrew LePera <dyn...@li...> > Date: Saturday, October 28, 2000 2:13 PM > Subject: Re: [Dynapi-Dev] (no subject) |