From 099cd75a4287c569481cd6df1f16e3f80ed3573c Mon Sep 17 00:00:00 2001 From: Mike Fulcher Date: Mon, 15 Aug 2022 09:33:56 +1200 Subject: [PATCH 1/2] Don't re-assign NoTargetError This is in keeping with what looks like the original intention of the Coffeescript source file - that only NoTargetErrors are caught, and other errors are thrown. --- pace.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pace.js b/pace.js index 0831a47..cb63b7e 100644 --- a/pace.js +++ b/pace.js @@ -302,7 +302,11 @@ try { this.getElement().parentNode.removeChild(this.getElement()); } catch (_error) { - NoTargetError = _error; + if (_error instanceof NoTargetError) { + // This is ok + } else { + throw _error + } } return this.el = void 0; }; @@ -961,7 +965,11 @@ try { bar.render(); } catch (_error) { - NoTargetError = _error; + if (_error instanceof NoTargetError) { + // This is ok + } else { + throw _error + } } if (!document.querySelector('.pace')) { return setTimeout(Pace.start, 50); @@ -983,4 +991,4 @@ } } -}).call(this); \ No newline at end of file +}).call(this); From 7b03824c67865a96a7fb9cdea8422356e46d972e Mon Sep 17 00:00:00 2001 From: Mike Fulcher Date: Tue, 16 Aug 2022 11:50:05 +1200 Subject: [PATCH 2/2] Don't check if the error is a NoTargetError The way that coffeescript compiles the code means that NoTargetError does not actually act as its own class at all, so `error instanceof NoTargetError` always returns `false`. Since the original error handling code did not raise any exceptions at all (regardless if it was a NoTargetError or not), I've done the same here so that the functionality is identical (save for not reassigning NoTargetError). --- pace.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pace.js b/pace.js index cb63b7e..29dcf7f 100644 --- a/pace.js +++ b/pace.js @@ -302,11 +302,7 @@ try { this.getElement().parentNode.removeChild(this.getElement()); } catch (_error) { - if (_error instanceof NoTargetError) { - // This is ok - } else { - throw _error - } + // This is ok } return this.el = void 0; }; @@ -965,11 +961,7 @@ try { bar.render(); } catch (_error) { - if (_error instanceof NoTargetError) { - // This is ok - } else { - throw _error - } + // This is ok } if (!document.querySelector('.pace')) { return setTimeout(Pace.start, 50);