|
From: Robert R. <rai...@us...> - 2000-10-29 21:22:27
|
Hi,
I beleive there is a bug in the patch:
DynDocument.prototype.recreateAll=function() {
this.setBgColor(this.bgColor)
this.setFgColor(this.fgColor)
if (this.children) return //<- should be (!this.children)
for (var i in this.children) {
if (this.children[i].created) {
if (this.children[i].elm) this.children[i].elm=null
this.children[i].deleteElement()
this.children[i].createElement()
}
}
}
Also, I think that you need to use the hasChildren method instead,
because if you add a child and then remove it, the .children will be
true, but have a length of zero. So, I would sugget using the
hasChildren check instead.
Later,
Robert <rai...@us...>
> I think I've found a fix for the problem with children arrays being shared
> between widgets made with the widgetX model.
>
> The problem:
>
> Widget.prototype = new DynLayer()
>
> When this is done, the properties of the base DynLayer are *shared* with
> every Widget made with the constructor.
>
> Most of these shared properties are reassigned to unique ones when
> createElement is called on the Widget. However, the children array is not,
> and it gives the effect that all Widgets share the same children array.
>
> So I've posted a patch for DynLayer and DynDocument that assigns the
> this.children array only when you use addChild. DynLayer-based widgets
> won't have a children array until you add at least one child.
>
> I also made changes to removeChild, removeAllChildren, etc. that check for
> the existence of the child array before proceeding.
>
> This should ensure that the children array is a unique object for each
> widget, and not the common one in the Widget prototype. Then you can safely
> use WidgetX to simulate inheritance without the shared-properties problem.
>
> The only consideration is if you build a widget that manipulates the
> children array, you should test it it exists first (it's initially set to
> null until you use addChild).
>
> I've only tested it on a few IBS and GUI widgets, but it seems to work
> across the board. I've posted the patch for review.
>
> scottandrew
>
>
>
>
>
>
> ------
> Scott Andrew LePera
> DHTML / Scripting / CGI and other neat stuff
> sc...@sc...
> http://www.scottandrew.com
>
> _______________________________________________
> Dynapi-Dev mailing list
> Dyn...@li...
> http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
|