From: Leif W <war...@us...> - 2005-09-01 15:37:28
|
> From: "SourceForge.net" <no...@so...> > Sent: 2005 September 01 Thursday 10:14 > ---------------------------------------------------------------------- > > Comment By: Andrew Gillett (agillett) > Date: 2005-09-01 08:04 > > Message: > Logged In: YES > user_id=134108 > > The removeFromParent() function deletes the DIV element > associated with the DynLayer from the DOM. The addChild() > function creates a new element and inserts it into the > parents (layer1) DOM. I didn't see the "delete" (builtin?) function called, but did see false and null assignments. removeFromParent in event.js line 196 calls removeChild removeChild in event.js line185 calls _remove, sets dyndoc, elm, css, and doc to null, and calls dropChildIndex _remove in dynlayer_base.js line 107 calls removeChild (recursive), else sets outerHTML to empty string, elm to null, and releases key and mouse events deleteFromParent in event.js line 172 calls deleteChild deleteChild in event.js line 164 calls _destroy and dropChildIndex _destroy is defined differently in dyndocument and dynlayer objects as they do different things we want the _destroy for dynlayer objects _destroy in dynlayer_base.js line 76 calls _destroyAllChildren, removeAllEventListeners, _remove, and sets a bunch of values to null. To me, they seem to be doing nearly the same thing. They both call _remove. I don't understand why there's functions with remove, delete, and destroy which all do similar things, namely render an object's contents or the object itself unusable. Why do we need three functions to do nearly the same thing? If we do need three, then we can pick more suitable names for them. The following ideas would break compatibility but with the benefit of greatly simplifying things. For me, removeFromParent should remove the parent/child relationship in DynAPI, leave the object intact, and hide it. deleteFromParent should destroy the object. Then destroy is superfluous. But that is still confusing because DOS and U*IX file system commands rm and del tend to be thought of as the same thing. Since it's parent/child relationship, maybe call the function removeFromParent orphan and call removeChild disown or abandon. ;-) Then we can use destroy, delete or remove (pick one, I like delete) for the function names which obliterate objects and free memory back to the browser. Disown and abandon however may or may not describe it well, it's more like unlink, but that is a Perl/UN*X synonym for file deletion or removal. detachFromParent, detachChild might be a better choice. > The problem is that the _create() function in dynlayer_ie.js > uses "document.createElement()" to create the new DIV > element. Because this action is initiated from your "Set > Desktop" button, the "document" variable refers to the menu > document, not the content document. You cannot add an > element created in one frame to the DOM of another frame. Oh yeah, you can't just take a DOM element and unhook it, can you? If it's created using DOM, it's got to be tucked away in a hidden part of the DOM. We could make a hidden orphanage, and just put all the orphans there. :-) Or if using detach names simply called it detached. Is that a feasible idea? Leif |