Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch nprogress@0.2.0 for the project I'm working on.
nprogress@0.2.0
Sometimes the component failed to load since not all conditions to handle the component are met. These changes add checks to avoid runtime errors.
Here is the diff that solved my problem:
diff --git a/node_modules/nprogress/nprogress.js b/node_modules/nprogress/nprogress.js index b23b300..d99e2d6 100644 --- a/node_modules/nprogress/nprogress.js +++ b/node_modules/nprogress/nprogress.js @@ -240,11 +240,14 @@ spinner && removeElement(spinner); } + if(!parent){ + parent = document.querySelector('body') + } + if (parent != document.body) { addClass(parent, 'nprogress-custom-parent'); } - - parent.appendChild(progress); + parent?.appendChild(progress); return progress; }; @@ -433,7 +436,8 @@ if (hasClass(oldList, name)) return; // Trim the opening space. - element.className = newList.substring(1); + if(element) + element.className = newList.substring(1); } /** @@ -460,7 +464,7 @@ */ function classList(element) { - return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' '); + return (' ' + (element?.className || '') + ' ').replace(/\s+/gi, ' '); } /**
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
nprogress@0.2.0
for the project I'm working on.Sometimes the component failed to load since not all conditions to handle the component are met. These changes add checks to avoid runtime errors.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: