fix(common/js/event-safety): 修复dataset访问可能的空指针问题
使用可选链操作符避免target为null/undefined时访问dataset报错
This commit is contained in:
@@ -44,7 +44,7 @@ export class EventSafety {
|
||||
// 安全的方法
|
||||
matches: (selector) => EventSafety.safeMatches(target, selector),
|
||||
// 数据集
|
||||
dataset: target.dataset || {}
|
||||
dataset: target?.dataset || {}
|
||||
}
|
||||
|
||||
return safeTarget
|
||||
|
||||
Reference in New Issue
Block a user