perf: 优化水印在控制台可以hide的问题 (#3732)

This commit is contained in:
joeguang 2024-04-11 14:36:24 +08:00 committed by GitHub
parent 13b031eef9
commit 9784cdc840
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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']);
}
}
}