Skip to content

Commit

Permalink
fix: 修复降级模式会丢失事件监听器 (#758)
Browse files Browse the repository at this point in the history
Co-authored-by: Wang LuoLong <wangll31@asiainfo.com>
  • Loading branch information
evolzzz and Wang LuoLong authored Dec 18, 2023
1 parent 2f27479 commit 534e865
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/wujie-core/src/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function recordEventListeners(iframeWindow: Window) {
// 添加事件缓存
const elementListenerList = sandbox.elementEventCacheMap.get(this);
if (elementListenerList) {
if (!elementListenerList.find((listener) => listener.handler === handler)) {
if (!elementListenerList.find((listener) => listener.type === type && listener.handler === handler)) {
elementListenerList.push({ type, handler, options });
}
} else sandbox.elementEventCacheMap.set(this, [{ type, handler, options }]);
Expand All @@ -299,7 +299,7 @@ function recordEventListeners(iframeWindow: Window) {
// 清除缓存
const elementListenerList = sandbox.elementEventCacheMap.get(this);
if (elementListenerList) {
const index = elementListenerList?.findIndex((ele) => ele.handler === handler);
const index = elementListenerList?.findIndex((ele) => ele.type === type && ele.handler === handler);
elementListenerList.splice(index, 1);
}
if (!elementListenerList?.length) {
Expand Down

0 comments on commit 534e865

Please sign in to comment.