feat(jqLite): support data() getter and data(obj) setter

... just like jquery does
This commit is contained in:
Igor Minar
2012-05-03 21:42:51 -07:00
parent 5df7e6fae5
commit ee579a071a
2 changed files with 72 additions and 14 deletions

View File

@@ -215,7 +215,21 @@ function JQLiteData(element, key, value) {
}
cache[key] = value;
} else {
return cache ? cache[key] : null;
if (isDefined(key)) {
if (isObject(key)) {
if (!cacheId) element[jqName] = cacheId = jqNextId();
jqCache[cacheId] = cache = (jqCache[cacheId] || {});
extend(cache, key);
} else {
return cache ? cache[key] : undefined;
}
} else {
if (!cacheId) element[jqName] = cacheId = jqNextId();
return cache
? cache
: cache = jqCache[cacheId] = {};
}
}
}