diff --git a/src/lib/eventManager.js b/src/lib/eventManager.js index d981176..f303a89 100644 --- a/src/lib/eventManager.js +++ b/src/lib/eventManager.js @@ -1,7 +1,7 @@ const eventManager = new Map(); function createSyntheticEvent(event) { - let propagated = false; + let propagationStopped = false; return { type: event.type, target: event.target, @@ -10,24 +10,23 @@ function createSyntheticEvent(event) { event.preventDefault(); }, stopPropagation() { - propagated = true; + propagationStopped = true; event.stopPropagation(); }, - isPropatation() { - return propagated; + isPropagationStopped() { + return propagationStopped; }, nativeEvent: event, }; } -function eventHandler(event) { +function handleGlobalEvent(event) { event = createSyntheticEvent(event); const eventType = event.type; const handlers = eventManager.get(eventType); let currentElement = event.target; - - while (currentElement && !event.isPropatation()) { + while (currentElement && !event.isPropagationStopped()) { if (handlers.has(currentElement)) { const handler = handlers.get(currentElement); handler(event); @@ -38,8 +37,8 @@ function eventHandler(event) { export function setupEventListeners(root) { eventManager.forEach((_, eventType) => { - root?.removeEventListener(eventType, eventHandler); - root?.addEventListener(eventType, eventHandler); + root?.removeEventListener(eventType, handleGlobalEvent); + root?.addEventListener(eventType, handleGlobalEvent); }); } diff --git a/src/lib/updateElement.js b/src/lib/updateElement.js index 6044543..7ba5fd6 100644 --- a/src/lib/updateElement.js +++ b/src/lib/updateElement.js @@ -10,9 +10,9 @@ function isChangedAttributes(originNewProps, originOldProps) { return true; } - const mergesProps = { ...originOldProps, ...originNewProps }; - return Object.keys(mergesProps ?? {}).some( - (key) => mergesProps[key] !== originOldProps[key], + const mergedProps = { ...originOldProps, ...originNewProps }; + return Object.keys(mergedProps ?? {}).some( + (key) => mergedProps[key] !== originOldProps[key], ); }