From cd827e769df6cda2d9bdee76f7f32764c395339d Mon Sep 17 00:00:00 2001 From: Luuk Bosma Date: Wed, 17 Feb 2021 14:26:19 +0100 Subject: [PATCH 1/3] Fixing some Ajax calls not completing obj["on" + event] was overwritten also when addEventListener was available. Now adding an event fallback when addEventListener is unavailable. The original event (when available) is first added to the list, and then one or more callbacks are added. Fixes #509 Signed-off-by: Luuk Bosma --- pace.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pace.js b/pace.js index 2038761f..ed7dffed 100644 --- a/pace.js +++ b/pace.js @@ -49,7 +49,25 @@ cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame; addEventListener = function(obj, event, callback) { - return (typeof obj.addEventListener === "function" ? obj.addEventListener(event, callback, false) : void 0) || (obj["on" + event] = callback); + if (typeof obj.addEventListener === "function") { + return obj.addEventListener(event, callback, false); + } else { + return function() { + if (typeof obj["on" + event] !== "function" || typeof obj["on" + event].eventListeners !== "object") { + var eventListeners = new Events(); + if (typeof obj["on" + event] === "function") { + eventListeners.on(event, obj["on" + event]); + } + obj["on" + event] = function(evt) { + return eventListeners.trigger(event, evt); + }; + obj["on" + event].eventListeners = eventListeners; + } else { + var eventListeners = obj["on" + event].eventListeners; + } + eventListeners.on(event, callback); + }(); + } }; if (requestAnimationFrame == null) { From 9402ceab308c9562023cf8611c3b8325db6182e6 Mon Sep 17 00:00:00 2001 From: Zachary Miller Date: Tue, 2 Mar 2021 22:53:48 -0500 Subject: [PATCH 2/3] 1.2.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 874d0bda..45a2a37b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pace-js", - "version": "1.2.3", + "version": "1.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pace-js", - "version": "1.2.3", + "version": "1.2.4", "license": "MIT" } } diff --git a/package.json b/package.json index b6ea6c69..b4123812 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pace-js", - "version": "1.2.3", + "version": "1.2.4", "description": "Automatically add a progress bar to your site.", "main": "pace.js", "scripts": { From 5ba323cbf9ab2ca3213db3eec4f0b9eee8b41d64 Mon Sep 17 00:00:00 2001 From: Zachary Miller Date: Tue, 2 Mar 2021 22:57:07 -0500 Subject: [PATCH 3/3] Fixing some Ajax calls not completing --- pace-theme-default.css | 2 +- pace-theme-default.min.css | 2 +- pace.js | 2 +- pace.min.js | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pace-theme-default.css b/pace-theme-default.css index d9405a10..04907b4e 100644 --- a/pace-theme-default.css +++ b/pace-theme-default.css @@ -1,5 +1,5 @@ /*! - * pace.js v1.2.3 | Default theme + * pace.js v1.2.4 | Default theme * https://github.com/CodeByZach/pace/ * Licensed MIT © HubSpot, Inc. */ diff --git a/pace-theme-default.min.css b/pace-theme-default.min.css index 287907af..7c7404e7 100644 --- a/pace-theme-default.min.css +++ b/pace-theme-default.min.css @@ -1,5 +1,5 @@ /*! - * pace.js v1.2.3 | Default theme + * pace.js v1.2.4 | Default theme * https://github.com/CodeByZach/pace/ * Licensed MIT © HubSpot, Inc. */ diff --git a/pace.js b/pace.js index ed7dffed..0831a471 100644 --- a/pace.js +++ b/pace.js @@ -1,5 +1,5 @@ /*! - * pace.js v1.2.3 + * pace.js v1.2.4 * https://github.com/CodeByZach/pace/ * Licensed MIT © HubSpot, Inc. */ diff --git a/pace.min.js b/pace.min.js index 40c74bd5..b82e2571 100644 --- a/pace.min.js +++ b/pace.min.js @@ -1,6 +1,6 @@ /*! - * pace.js v1.2.3 + * pace.js v1.2.4 * https://github.com/CodeByZach/pace/ * Licensed MIT © HubSpot, Inc. */ -(function(){function o(t,e){return function(){return t.apply(e,arguments)}}var u,c,i,n,y,t,l,v,r,s,a,e,p,w,b,h,f,d,g,m,k,S,q,x,L,P,T,R,j,O,E,M,A,C,N,_,F,U,W,X,D,H,I,z,G,B=[].slice,J={}.hasOwnProperty,K=function(t,e){for(var n in e)J.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},Q=[].indexOf||function(t){for(var e=0,n=this.length;e\n
\n\n
',null!=t.firstChild?t.insertBefore(this.el,t.firstChild):t.appendChild(this.el)}return this.el},Z.prototype.finish=function(){var t=this.getElement();return t.className=t.className.replace("pace-active","pace-inactive"),document.body.className=document.body.className.replace("pace-running ","pace-done ")},Z.prototype.update=function(t){return this.progress=t,y.trigger("progress",t),this.render()},Z.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(t){n=t}return this.el=void 0},Z.prototype.render=function(){var t,e,n,r,s,o,i;if(null==document.querySelector(P.target))return!1;for(t=this.getElement(),r="translate3d("+this.progress+"%, 0, 0)",s=0,o=(i=["webkitTransform","msTransform","transform"]).length;sP.eventLag.sampleCount&&o.shift(),e=p(o),++s>=P.eventLag.minSamples&&ethis.progress&&(this.progress+=this.catchup*t),e=1-Math.pow(this.progress/100,P.easeFactor),this.progress+=e*this.rate*t,this.progress=Math.min(this.lastProgress+P.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},v=ot,b=e=N=w=O=C=null,y.running=!1,S=function(){if(P.restartOnPushState)return y.restart()},null!=window.history.pushState&&(H=window.history.pushState,window.history.pushState=function(){return S(),H.apply(window.history,arguments)}),null!=window.history.replaceState&&(z=window.history.replaceState,window.history.replaceState=function(){return S(),z.apply(window.history,arguments)}),l={ajax:u,elements:G,document:K,eventLag:m},(x=function(){var t,e,n,r,s,o,i,a;for(y.sources=C=[],e=0,r=(o=["ajax","elements","document","eventLag"]).length;e\n
\n\n
',null!=t.firstChild?t.insertBefore(this.el,t.firstChild):t.appendChild(this.el)}return this.el},$.prototype.finish=function(){var t=this.getElement();return t.className=t.className.replace("pace-active","pace-inactive"),document.body.className=document.body.className.replace("pace-running ","pace-done ")},$.prototype.update=function(t){return this.progress=t,y.trigger("progress",t),this.render()},$.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(t){n=t}return this.el=void 0},$.prototype.render=function(){var t,e,n,r,s,o,i;if(null==document.querySelector(T.target))return!1;for(t=this.getElement(),r="translate3d("+this.progress+"%, 0, 0)",s=0,o=(i=["webkitTransform","msTransform","transform"]).length;sT.eventLag.sampleCount&&o.shift(),e=h(o),++s>=T.eventLag.minSamples&&ethis.progress&&(this.progress+=this.catchup*t),e=1-Math.pow(this.progress/100,T.easeFactor),this.progress+=e*this.rate*t,this.progress=Math.min(this.lastProgress+T.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},v=it,b=e=_=w=E=N=null,y.running=!1,q=function(){if(T.restartOnPushState)return y.restart()},null!=window.history.pushState&&(I=window.history.pushState,window.history.pushState=function(){return q(),I.apply(window.history,arguments)}),null!=window.history.replaceState&&(G=window.history.replaceState,window.history.replaceState=function(){return q(),G.apply(window.history,arguments)}),l={ajax:u,elements:k,document:B,eventLag:Q},(x=function(){var t,e,n,r,s,o,i,a;for(y.sources=N=[],e=0,r=(o=["ajax","elements","document","eventLag"]).length;e