Skip to content

Commit

Permalink
perf: 优化水印在控制台可以hide的问题 (vbenjs#3732)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeguang authored Apr 11, 2024
1 parent 13b031e commit 9784cdc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/hooks/web/useWatermark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,15 @@ const obFn = () => {
target?.parentElement?.appendChild(node as HTMLElement);
}
}
if (mutation.attributeName === 'style' && mutation.target) {
if (mutation.type === 'attributes' && mutation.target) {
// 修复控制台可以”Hide element” 的问题
const _target = mutation.target as HTMLElement;
const target = findTargetNode(_target);
if (target) {
const { waterMarkOptions = {} } = target;
resetWatermarkStyle(
_target as HTMLElement,
_target?.['data-watermark-text'],
waterMarkOptions,
);
// 禁止改属性 包括class 修改以后 mutation.type 也等于 'attributes'
// 先解除监听 再加一下
clearAll();
target.setWatermark(target.targetElement?.['data-watermark-text']);
}
}
}
Expand Down

0 comments on commit 9784cdc

Please sign in to comment.