-
-
Notifications
You must be signed in to change notification settings - Fork 364
fix(Watermark): multiple elements not displayed #6058
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 GuideRefactored the watermark monitoring function to simplify element detection by replacing manual child checks with a querySelector lookup for the watermark element. 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:
- Consider adding a null‐check right after the
querySelectorso you don’t callgetComputedStyleonnullwhen no.bb-watermark-bgis found. - If you expect multiple watermark elements, replace
querySelectorwithquerySelectorAlland loop through each match rather than only handling the first one.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 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.
| const mark = el.querySelector('.bb-watermark-bg'); | ||
| const style = getComputedStyle(mark); |
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): Guard against null result from querySelector to avoid getComputedStyle error
Guard against mark being null before calling getComputedStyle. For example:
if (!mark) {
clearWatermark(watermark);
return;
}| const mark = el.querySelector('.bb-watermark-bg'); | |
| const style = getComputedStyle(mark); | |
| const mark = el.querySelector('.bb-watermark-bg'); | |
| if (!mark) { | |
| clearWatermark(watermark); | |
| return; | |
| } | |
| const style = getComputedStyle(mark); |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6058 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 701 701
Lines 30956 30956
Branches 4378 4378
=========================================
Hits 30956 30956 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6056
Summary By Copilot
This pull request simplifies the watermark monitoring logic in the
Watermark.razor.jsfile by replacing a manual child element check with a more robust query selector. This change improves code readability and reduces the likelihood of errors when identifying the watermark element.Simplification of watermark monitoring logic:
src/BootstrapBlazor/Components/Watermark/Watermark.razor.js: Replaced the manual child element checks and class name validation with aquerySelectorcall to directly find the watermark element (.bb-watermark-bg). This reduces complexity and ensures the correct element is targeted.Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Simplify watermark monitoring by replacing manual child element checks with a querySelector lookup for the
.bb-watermark-bgelement to ensure correct watermark detectionBug Fixes:
querySelectorinstead of manual child indexingEnhancements:
Watermark.razor.jsto streamline the monitoring logic