summaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal')
-rw-r--r--lib/internal/once.js3
-rw-r--r--lib/internal/onlyOnce.js3
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/internal/once.js b/lib/internal/once.js
index 11678dc..f601185 100644
--- a/lib/internal/once.js
+++ b/lib/internal/once.js
@@ -1,7 +1,8 @@
export default function once(fn) {
return function () {
if (fn === null) return;
- fn.apply(this, arguments);
+ var callFn = fn;
fn = null;
+ callFn.apply(this, arguments);
};
}
diff --git a/lib/internal/onlyOnce.js b/lib/internal/onlyOnce.js
index f4241c8..355ff41 100644
--- a/lib/internal/onlyOnce.js
+++ b/lib/internal/onlyOnce.js
@@ -3,7 +3,8 @@
export default function onlyOnce(fn) {
return function() {
if (fn === null) throw new Error("Callback was already called.");
- fn.apply(this, arguments);
+ var callFn = fn;
fn = null;
+ callFn.apply(this, arguments);
};
}