diff options
author | Rob Loach <robloach@gmail.com> | 2014-10-16 06:14:42 -0700 |
---|---|---|
committer | Rob Loach <robloach@gmail.com> | 2014-10-16 06:14:42 -0700 |
commit | 09b340240d294f923ae2d0e90ac235830a0e71b0 (patch) | |
tree | 099d42f01010509d2c4b9965fdf6855307ea9995 /jquery.once.js | |
parent | 57bf227077907c9358cc4e97f679585140bc91c6 (diff) | |
parent | 3fa3482b3c02221ae6380980630b35729fc763f9 (diff) | |
download | jquery-once-09b340240d294f923ae2d0e90ac235830a0e71b0.zip jquery-once-09b340240d294f923ae2d0e90ac235830a0e71b0.tar.gz jquery-once-09b340240d294f923ae2d0e90ac235830a0e71b0.tar.bz2 |
Merge pull request #16 from theodoreb/once-id-required
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() { |