diff options
| author | Igor Minar | 2012-05-03 21:41:40 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-05-03 23:31:28 -0700 |
| commit | 5df7e6fae5c1045b8d988a6fa06fef674a4527da (patch) | |
| tree | 6cf80ccadcf67f1f4877baa127fcbaa48d4be957 /src | |
| parent | fff31d8d612430caf10a61a85e81e8c6c3629138 (diff) | |
| download | angular.js-5df7e6fae5c1045b8d988a6fa06fef674a4527da.tar.bz2 | |
style(jqLite): clean up the code
Diffstat (limited to 'src')
| -rw-r--r-- | src/jqLite.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/jqLite.js b/src/jqLite.js index 39c715f6..df878609 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -84,7 +84,7 @@ var jqCache = {}, ? function(element, type, fn) {element.removeEventListener(type, fn, false); } : function(element, type, fn) {element.detachEvent('on' + type, fn); }); -function jqNextId() { return (jqId++); } +function jqNextId() { return ++jqId; } var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; @@ -187,7 +187,8 @@ function JQLiteDealoc(element){ function JQLiteRemoveData(element) { var cacheId = element[jqName], - cache = jqCache[cacheId]; + cache = jqCache[cacheId]; + if (cache) { if (cache.bind) { forEach(cache.bind, function(fn, type){ @@ -206,6 +207,7 @@ function JQLiteRemoveData(element) { function JQLiteData(element, key, value) { var cacheId = element[jqName], cache = jqCache[cacheId || -1]; + if (isDefined(value)) { if (!cache) { element[jqName] = cacheId = jqNextId(); @@ -452,10 +454,16 @@ forEach({ // in a way that survives minification. if (((fn.length == 2 && (fn !== JQLiteHasClass && fn !== JQLiteController)) ? arg1 : arg2) === undefined) { if (isObject(arg1)) { + // we are a write, but the object properties are the key/values for(i=0; i < this.length; i++) { - for (key in arg1) { - fn(this[i], key, arg1[key]); + if (fn === JQLiteData) { + // data() takes the whole object in jQuery + fn(this[i], arg1); + } else { + for (key in arg1) { + fn(this[i], key, arg1[key]); + } } } // return self for chaining |
