summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jquery.once.js10
-rw-r--r--jquery.once.litcoffee11
2 files changed, 7 insertions, 14 deletions
diff --git a/jquery.once.js b/jquery.once.js
index dd825f4..affaaed 100644
--- a/jquery.once.js
+++ b/jquery.once.js
@@ -9,16 +9,12 @@
factory(jQuery);
}
})(function($) {
- var cache, uuid;
- cache = {};
+ var uuid;
uuid = 0;
$.fn.once = function(id) {
var name;
- if (typeof id !== "string") {
- if (!(id in cache)) {
- cache[id] = ++uuid;
- }
- id = cache[id];
+ if (!id) {
+ id = ++uuid;
}
name = "jquery-once-" + id;
return this.filter(function() {
diff --git a/jquery.once.litcoffee b/jquery.once.litcoffee
index 2f8fedc..0f0f237 100644
--- a/jquery.once.litcoffee
+++ b/jquery.once.litcoffee
@@ -20,7 +20,6 @@ and jQuery Once, in a number of different ways.
factory jQuery
return
) ($) ->
- cache = {}
uuid = 0
@@ -50,15 +49,13 @@ $('p').once('changecolor').css('color', 'green');
#### Source
$.fn.once = (id) ->
- if typeof id isnt "string"
- # Generate a numeric ID if the id passed is not a string.
- cache[id] = ++uuid unless id of cache
- id = cache[id]
+ # Generate a numeric id if the id doesn't exist.
+ id = ++uuid if !id
# Filter the elements by which do not have the data yet.
name = "jquery-once-" + id
- @filter(->
+ @filter ->
$(this).data(name) isnt true
- ).data name, true
+ .data name, true
### `.removeOnce()`