Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1cc3d28

Browse files
martinratinaudChrisCinelli
authored andcommitted
Add guard on classList function if element does not exist anymore
1 parent 33878ab commit 1cc3d28

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

‎nprogress.js‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@
8383

8484
if (n === 1) {
8585
// Fade out
86-
css(progress, {
87-
transition: 'none',
88-
opacity: 1
86+
css(progress, {
87+
transition: 'none',
88+
opacity: 1
8989
});
9090
progress.offsetWidth; /* Repaint */
9191

9292
setTimeout(function() {
93-
css(progress, {
94-
transition: 'all ' + speed + 'ms linear',
95-
opacity: 0
93+
css(progress, {
94+
transition: 'all ' + speed + 'ms linear',
95+
opacity: 0
9696
});
9797
setTimeout(function() {
9898
NProgress.remove();
@@ -220,7 +220,7 @@
220220
if (NProgress.isRendered()) return document.getElementById('nprogress');
221221

222222
addClass(document.documentElement, 'nprogress-busy');
223-
223+
224224
var progress = document.createElement('div');
225225
progress.id = 'nprogress';
226226
progress.innerHTML = Settings.template;
@@ -229,7 +229,7 @@
229229
perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
230230
parent = document.querySelector(Settings.parent),
231231
spinner;
232-
232+
233233
css(bar, {
234234
transition: 'all 0 linear',
235235
transform: 'translate3d(' + perc + '%,0,0)'
@@ -340,7 +340,7 @@
340340

341341
var queue = (function() {
342342
var pending = [];
343-
343+
344344
function next() {
345345
var fn = pending.shift();
346346
if (fn) {
@@ -355,10 +355,10 @@
355355
})();
356356

357357
/**
358-
* (Internal) Applies css properties to an element, similar to the jQuery
358+
* (Internal) Applies css properties to an element, similar to the jQuery
359359
* css method.
360360
*
361-
* While this helper does assist with vendor prefixed property names, it
361+
* While this helper does assist with vendor prefixed property names, it
362362
* does not perform any manipulation of values prior to setting styles.
363363
*/
364364

@@ -399,7 +399,7 @@
399399

400400
return function(element, properties) {
401401
var args = arguments,
402-
prop,
402+
prop,
403403
value;
404404

405405
if (args.length == 2) {
@@ -430,7 +430,7 @@
430430
var oldList = classList(element),
431431
newList = oldList + name;
432432

433-
if (hasClass(oldList, name)) return;
433+
if (hasClass(oldList, name)) return;
434434

435435
// Trim the opening space.
436436
element.className = newList.substring(1);
@@ -454,13 +454,13 @@
454454
}
455455

456456
/**
457-
* (Internal) Gets a space separated list of the class names on the element.
458-
* The list is wrapped with a single space on each end to facilitate finding
457+
* (Internal) Gets a space separated list of the class names on the element.
458+
* The list is wrapped with a single space on each end to facilitate finding
459459
* matches within the list.
460460
*/
461461

462462
function classList(element) {
463-
return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' ');
463+
return (' ' + (element&&element.className || '') + ' ').replace(/\s+/gi, ' ');
464464
}
465465

466466
/**
@@ -473,4 +473,3 @@
473473

474474
return NProgress;
475475
});
476-

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /