Skip to content

Commit

Permalink
refactor: 변수명, 함수명 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Geunbaek committed Dec 26, 2024
1 parent dcfbecb commit 62efcdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions src/lib/eventManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const eventManager = new Map();

function createSyntheticEvent(event) {
let propagated = false;
let propagationStopped = false;
return {
type: event.type,
target: event.target,
Expand All @@ -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);
Expand All @@ -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);
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/updateElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
}

Expand Down

0 comments on commit 62efcdd

Please sign in to comment.