mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
jquery data: closes #5224. Exposing the expando.
This commit is contained in:
parent
173c1477ae
commit
a273120291
@ -2,6 +2,8 @@ var expando = "jQuery" + now(), uuid = 0, windowData = {};
|
|||||||
|
|
||||||
jQuery.extend({
|
jQuery.extend({
|
||||||
cache: {},
|
cache: {},
|
||||||
|
|
||||||
|
expando:expando,
|
||||||
|
|
||||||
data: function( elem, name, data ) {
|
data: function( elem, name, data ) {
|
||||||
elem = elem == window ?
|
elem = elem == window ?
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
module("data");
|
module("data");
|
||||||
|
|
||||||
|
test("expando", function(){
|
||||||
|
expect(4);
|
||||||
|
|
||||||
|
equals("expando" in jQuery, true, "jQuery is exposing the expando");
|
||||||
|
|
||||||
|
var obj = {};
|
||||||
|
jQuery.data(obj, "foo", "bar");
|
||||||
|
|
||||||
|
equals(jQuery.expando in obj, true, "jQuery.data added an expando to the object");
|
||||||
|
|
||||||
|
var id = obj[jQuery.expando];
|
||||||
|
equals( id in jQuery.cache, true, "jQuery.data added an entry to jQuery.cache");
|
||||||
|
|
||||||
|
equals( jQuery.cache[id].foo, "bar", "jQuery.data worked correctly");
|
||||||
|
});
|
||||||
|
|
||||||
test("jQuery.data", function() {
|
test("jQuery.data", function() {
|
||||||
expect(5);
|
expect(5);
|
||||||
var div = jQuery("#foo")[0];
|
var div = jQuery("#foo")[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user