diff options
author | Théodore Biadala <theodore@biadala.net> | 2014-10-15 03:49:30 +0200 |
---|---|---|
committer | Théodore Biadala <theodore@biadala.net> | 2014-10-15 03:49:30 +0200 |
commit | 6c3c03d6c1b974c03f1276e65fc3f2bba5e4393e (patch) | |
tree | f97bc5195dcf938afcd6195d426d64ac90479f41 /jquery.once.js | |
parent | 57bf227077907c9358cc4e97f679585140bc91c6 (diff) | |
download | jquery-once-6c3c03d6c1b974c03f1276e65fc3f2bba5e4393e.zip jquery-once-6c3c03d6c1b974c03f1276e65fc3f2bba5e4393e.tar.gz jquery-once-6c3c03d6c1b974c03f1276e65fc3f2bba5e4393e.tar.bz2 |
Remove ability to call once() without a parameter
Diffstat (limited to 'jquery.once.js')
-rw-r--r-- | jquery.once.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/jquery.once.js b/jquery.once.js index 0b2bbb0..5469ab7 100644 --- a/jquery.once.js +++ b/jquery.once.js @@ -30,18 +30,13 @@ } }(function ($) { "use strict"; - var uuid = 0; /** * Filter elements by whether they have not yet been processed. * * @param {string} [id] - * (Optional) The data id used to determine whether the given elements have - * already been processed or not. - * - * When id is not provided, it becomes a unique identifier, depicted as a - * number. The element's data id will then be represented in the form of - * "jquery-once-#". + * The data id used to determine whether the given elements have already + * been processed or not. * * @returns jQuery element collection of elements that have now run once by * the given id. @@ -58,9 +53,12 @@ * @public */ $.fn.once = function (id) { + if (!id) { + throw new Error("An ID is required when calling jQuery.once()"); + } // 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); + var name = "jquery-once-" + id; // Filter the elements by which do not have the data yet. return this.filter(function() { |