Skip to content

Commit d141abb

Browse files
committed
refactor: 돔 렌더와 이벤트 바인딩 함수 분리
1 parent 4c198d1 commit d141abb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/TodoForm.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ export default class TodoForm {
88
) {
99
$target.appendChild(this.$form);
1010
this.render();
11+
this.setEvent();
1112
}
1213

1314
private render() {
1415
this.$form.innerHTML = `
1516
<input type="text" placeholder="할 일을 입력하세요" name="todo" minLength="2" autocomplete="off" />
1617
<button>추가</button>
1718
`;
19+
};
1820

21+
private setEvent() {
1922
this.$form.addEventListener("submit", (e) => {
2023
e.preventDefault();
2124
const $todo = this.$form.querySelector<HTMLInputElement>("input[name=todo]");
@@ -24,5 +27,5 @@ export default class TodoForm {
2427
$todo.value = "";
2528
this.onSubmit(text);
2629
});
27-
};
30+
}
2831
}

0 commit comments

Comments
 (0)