Release:jQuery 1.2/Internals
From jQuery JavaScript Library
« Back to the full jQuery 1.2 Release Notes.
Documentation Move
All documentation has now been moved out of the jQuery internal code and onto the jQuery Documentation Wiki. We're currently working on new tools to convert the documentation into the old XML format (so that sites like Visual jQuery can be updated for 1.2).
We'll be sure to let everyone know when that move is complete.
Expando Management
Expandos are properties that are attached to the object representations of DOM Nodes. Generally, the management of these properties can be quite messy (dealing with issues like garbage collection and name collision). jQuery has introduced a new API that plugins can use to manage the storage of data on elements.
The following methods have been added:
- jQuery.data(elem)
Returns a unique ID for the element - jQuery.data(elem, name)
Returns a named data store for the element - jQuery.data(elem, name, value)
Saves a value to the named data store - jQuery.removeData(elem)
Remove the expando from the element and the complete data store - jQuery.removeData(elem, name)
Removes just this one named data store
jQuery's .remove() and .empty() methods automatically clean up after themselves, removing any expandos and data stores for an element. Once an element leaves a DOM document their events are no longer intact. Thus, statements like so:
$("#foo").remove().appendTo("#bar");
should be written like so:
$("#foo").appendTo("#bar");
in order to avoid losing the bound events.