Skip to content

Commit

Permalink
fix: 修改判断,考虑初始绑定的事件为空的情况 (#15540)
Browse files Browse the repository at this point in the history
* fix: 修改判断,考虑初始绑定的事件为空的情况

* fix: 判断 oldEventHandler 存在再移除

---------

Co-authored-by: koppt <kopptsoft@gmail.com>
  • Loading branch information
shushu2013 and koppthe authored May 10, 2024
1 parent f45c37e commit 396253e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export const syncEvent = (
const eventStore = node.__events ||= {}
const oldEventHandler = eventStore[eventName]

if (!newEventHandler && oldEventHandler) {
node.removeEventListener(eventName, oldEventHandler)
if (!newEventHandler) {
oldEventHandler && node.removeEventListener(eventName, oldEventHandler)
} else {
if (oldEventHandler) {
if (oldEventHandler.fn === newEventHandler) {
Expand Down

0 comments on commit 396253e

Please sign in to comment.