Permalink
Browse files

only store to cache if elements are returned

  • Loading branch information...
1 parent b89c8cf commit e9a7eafa71a7e0b944e9b2d9c66c80d8799b895d @craigmaslowski committed Jan 17, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 elcacheo.js
View
@@ -29,9 +29,11 @@
get: function(selector, nocache) {
if (!this.cache[selector] || nocache)
if (this.scope)
- this.cache[selector] = $(selector, this.scope);
+ if ($(selector, this.scope).length > 0)
+ this.cache[selector] = $(selector, this.scope);
else
- this.cache[selector] = $(selector);
+ if ($(selector).length > 0)
+ this.cache[selector] = $(selector);
return this.cache[selector];
},

0 comments on commit e9a7eaf

Please sign in to comment.