Created
July 14, 2009 13:34
-
-
Save micmath/146935 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.jQuery = (window.jQuery || {}); | |
(function() { | |
var uuid = 0; | |
var expando = "jQuery" + +new Date; // like "jQuery123456789" | |
jQuery._cache = {}; | |
jQuery.data = function( elem, name, value ) { | |
if (typeof value == "undefined") { | |
return jQuery._getData(elem, name); | |
} | |
else { | |
return jQuery._setData(elem, name, value); | |
} | |
} | |
jQuery._setData = function( elem, name, value ) { | |
if (!elem[expando]) elem[expando] = ++uuid; | |
var id = elem[expando]; | |
if (!jQuery._cache[id]) jQuery._cache[id] = {}; | |
jQuery._cache[id][name] = value; | |
return id; | |
} | |
jQuery._getData = function( elem, name ) { | |
var id = elem[expando]; | |
return jQuery._cache[id][name]; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment