Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/BootstrapBlazor/Components/Watermark/Watermark.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function dispose(id) {
const updateWatermark = (records, watermark) => {
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')) {
Copy link
Contributor

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.

createWatermark(watermark);
return;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ const createWatermark = watermark => {
div.style.opacity = '1';
div.style.position = 'absolute';
div.style.inset = '0';
div.style.zIndex = '999';
div.style.zIndex = '9999';
div.classList.add("bb-watermark-bg");

const mark = el.querySelector('.bb-watermark-bg');
Expand Down Expand Up @@ -138,7 +138,7 @@ const monitor = watermark => {
clearWatermark(watermark);
return;
}
if (zIndex !== '999') {
if (zIndex !== '9999') {
clearWatermark(watermark);
return;
}
Expand Down