From a2731202917f8e90cad94ee574241d1626dc7fb6 Mon Sep 17 00:00:00 2001 From: Ariel Flesler Date: Mon, 14 Sep 2009 22:34:04 +0000 Subject: [PATCH] jquery data: closes #5224. Exposing the expando. --- src/data.js | 2 ++ test/unit/data.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/data.js b/src/data.js index 03116e4..d03d51f 100644 --- a/src/data.js +++ b/src/data.js @@ -2,6 +2,8 @@ var expando = "jQuery" + now(), uuid = 0, windowData = {}; jQuery.extend({ cache: {}, + + expando:expando, data: function( elem, name, data ) { elem = elem == window ? diff --git a/test/unit/data.js b/test/unit/data.js index 6b79da2..46e46ed 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -1,5 +1,21 @@ 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() { expect(5); var div = jQuery("#foo")[0]; -- 1.7.10.4