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 c533489

Browse files
committed
set dom
1 parent a0ab16c commit c533489

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

‎nprogress.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,14 @@
230230
progress.id = 'nprogress';
231231
progress.innerHTML = Settings.template;
232232

233-
var bar = progress.querySelector(Settings.barSelector),
234-
perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
235-
parent = document.querySelector(Settings.parent),
236-
spinner;
233+
234+
235+
var bar = progress.querySelector(Settings.barSelector),
236+
perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
237+
parent = isDOM(Settings.parent)
238+
? Settings.parent
239+
: document.querySelector(Settings.parent),
240+
spinner
237241

238242
css(bar, {
239243
transition: 'all 0 linear',
@@ -259,7 +263,10 @@
259263

260264
NProgress.remove = function() {
261265
removeClass(document.documentElement, 'nprogress-busy');
262-
removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
266+
var parent = isDOM(Settings.parent)
267+
? Settings.parent
268+
: document.querySelector(Settings.parent)
269+
removeClass(parent, 'nprogress-custom-parent')
263270
var progress = document.getElementById('nprogress');
264271
progress && removeElement(progress);
265272
};
@@ -302,6 +309,18 @@
302309
* Helpers
303310
*/
304311

312+
function isDOM (obj) {
313+
if (typeof HTMLElement === 'object') {
314+
return obj instanceof HTMLElement
315+
}
316+
return (
317+
obj &&
318+
typeof obj === 'object' &&
319+
obj.nodeType === 1 &&
320+
typeof obj.nodeName === 'string'
321+
)
322+
}
323+
305324
function clamp(n, min, max) {
306325
if (n < min) return min;
307326
if (n > max) return max;

0 commit comments

Comments
(0)

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