summaryrefslogtreecommitdiffstats
path: root/jquery.once.js
diff options
context:
space:
mode:
authorRob Loach <robloach@gmail.com>2014-12-15 09:56:28 -0500
committerRob Loach <robloach@gmail.com>2014-12-15 09:56:28 -0500
commit6a2ab3c7f9d58f2d47398ac29af06dec14c4612e (patch)
tree54a03afe7b3e83ec3489dd719a9b710896656e4c /jquery.once.js
parent03027a958db2e5af6c49156f97b8879cdc612a65 (diff)
parent779c426bf61ec43488a91bac78faf3971333e4cf (diff)
downloadjquery-once-6a2ab3c7f9d58f2d47398ac29af06dec14c4612e.zip
jquery-once-6a2ab3c7f9d58f2d47398ac29af06dec14c4612e.tar.gz
jquery-once-6a2ab3c7f9d58f2d47398ac29af06dec14c4612e.tar.bz2
Merge pull request #23 from theodoreb/default-parameter
Add a default value for once name and check once parameter is a string
Diffstat (limited to 'jquery.once.js')
-rw-r--r--jquery.once.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/jquery.once.js b/jquery.once.js
index 4664218..87741f9 100644
--- a/jquery.once.js
+++ b/jquery.once.js
@@ -53,8 +53,9 @@
* @public
*/
$.fn.once = function (id) {
- if (!id) {
- throw new Error("An ID is required when calling jQuery.once()");
+ id = id || "once";
+ if (typeof id !== "string") {
+ throw new Error("jQuery.once() parameter MUST be a string");
}
// Build the name for the data identifier. Generate a new unique id if the
// id parameter is not provided.