diff options
author | Rob Loach <robloach@gmail.com> | 2014-10-08 14:55:22 -0400 |
---|---|---|
committer | Rob Loach <robloach@gmail.com> | 2014-10-08 14:55:22 -0400 |
commit | a10ba8f605279314a3bac2f5c61c7b6fea98ab88 (patch) | |
tree | 37460e36854cb91d457853d4fea6c9e55713bc0a /jquery.once.js | |
parent | 4c862ae108fc69e17495f4169400ba9f41439228 (diff) | |
download | jquery-once-a10ba8f605279314a3bac2f5c61c7b6fea98ab88.zip jquery-once-a10ba8f605279314a3bac2f5c61c7b6fea98ab88.tar.gz jquery-once-a10ba8f605279314a3bac2f5c61c7b6fea98ab88.tar.bz2 |
Remove unneeded cache variable
Diffstat (limited to 'jquery.once.js')
-rw-r--r-- | jquery.once.js | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/jquery.once.js b/jquery.once.js index 054ceb4..c6e48b3 100644 --- a/jquery.once.js +++ b/jquery.once.js @@ -18,7 +18,7 @@ } }(function ($) { "use strict"; - var cache = {}, uuid = 0; + var uuid = 0; /** * Filter elements by whether they have not yet been processed. @@ -44,17 +44,11 @@ * @global */ $.fn.once = function (id) { - if (typeof id !== 'string') { - // Generate a numeric ID if the id passed is not a string. - if (!(id in cache)) { - cache[id] = ++uuid; - } - id = cache[id]; - } + // Build the name for the data identifier. Generate a new unique id if the + // id parameter is not provided. + var name = 'jquery-once-' + (id || ++uuid); // Filter the elements by which do not have the data yet. - var name = 'jquery-once-' + id; - return this.filter(function() { return $(this).data(name) !== true; }).data(name, true); |