-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(Watermark): update logic to prevent errors #5791
New issue
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
Conversation
Reviewer's Guide by SourceryThis pull request enhances the watermark component by addressing potential errors and improving its visibility. It includes a null check to prevent errors when accessing class lists and increases the z-index to ensure the watermark is displayed above other elements. Sequence diagram for updating the watermarksequenceDiagram
participant MutationObserver
participant DOM
participant Watermark
MutationObserver->>DOM: Detects removed nodes
DOM->>MutationObserver: Returns removed nodes
MutationObserver->>DOM: Checks if dom.classList exists
alt dom.classList exists
MutationObserver->>DOM: Checks if removed node has class 'bb-watermark-bg'
DOM->>MutationObserver: Returns true if class exists
MutationObserver->>Watermark: Calls createWatermark(watermark)
Watermark->>DOM: Creates and adds watermark to DOM
else dom.classList does not exist
MutationObserver->>MutationObserver: Skips watermark creation
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a comment explaining why the z-index was increased to 9999.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| for (const record of records) { | ||
| for (const dom of record.removedNodes) { | ||
| if (dom.classList.contains('bb-watermark-bg')) { | ||
| if (dom.classList && dom.classList.contains('bb-watermark-bg')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Added null-check for classList enhances robustness.
The additional check prevents runtime errors when 'dom' may not have a classList. Ensure similar checks are applied if there are other DOM manipulations that assume element properties.
Suggested implementation:
if (div && div.style && div.classList) {
div.style.opacity = '1';
div.style.position = 'absolute';
div.style.inset = '0';
div.style.zIndex = '9999';
div.classList.add("bb-watermark-bg");
} let mark;
if (el && typeof el.querySelector === 'function') {
mark = el.querySelector('.bb-watermark-bg');
}If there are any other places in this file (or related files) where DOM properties are accessed without checking for null (or property existence), similar conditional checks are recommended.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5791 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 658 658
Lines 30056 30056
Branches 4243 4243
=========================================
Hits 30056 30056 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #5790
Summary By Copilot
This pull request includes several changes to the
src/BootstrapBlazor/Components/Watermark/Watermark.razor.jsfile to improve the watermark functionality. The most important changes are as follows:Improvements to watermark handling:
updateWatermarkfunction: Added a check to ensuredom.classListis not null before callingcontainsto prevent potential errors.Adjustments to z-index values:
createWatermarkfunction: Increased thez-indexvalue from999to9999to ensure the watermark is displayed above other elements.monitorfunction: Updated thez-indexcheck from999to9999to match the newz-indexvalue set increateWatermark.Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Update watermark component to improve error handling and z-index positioning
Bug Fixes:
Enhancements: