Open
Conversation
added 2 commits
March 13, 2026 10:20
ryu-won
reviewed
Mar 15, 2026
Comment on lines
+99
to
+106
| .dateBox { | ||
| margin-top: 8px; | ||
|
|
||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| gap: 16px; | ||
| } |
Comment on lines
+132
to
+137
| .inputArea { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| gap: 8px; | ||
| } |
| listItem.appendChild(checkbox); | ||
| listItem.appendChild(todoText); | ||
| listItem.appendChild(deleteButton); | ||
| todoList.appendChild(listItem); |
There was a problem hiding this comment.
todoList.appendChild(listItem)이 forEach 안에서 반복 호출되고 있는데,
todoList는 이미 실제 DOM에 붙어있는 요소라 호출할 때마다 리플로우가 발생해요!
Suggested change
| todoList.appendChild(listItem); | |
| const fragment = document.createDocumentFragment(); | |
| todoArray.forEach(function (todo, index) { | |
| // 로직 그대로..... | |
| fragment.appendChild(listItem); | |
| }); | |
| todoList.appendChild(fragment); // DOM 변경 1번만!` |
DocumentFragment는 메모리 안에만 존재하는 가상의 임시 컨테이너입니다. 실제 DOM에 붙어있지 않아서 아무리 조작해도 리플로우가 발생하지 않고, 다 조립된 후 마지막에 한 번만 DOM에 추가하기 때문에 성능이 좋아져요!
| if (event.key === "Enter") { | ||
| addTodo(); | ||
| } | ||
| }); |
There was a problem hiding this comment.
중복으로 todo가 추가되는 문제가 있는데 한글이 조합문자라서 그런 것 같아요. keydown 이벤트가 아니라 keyup으로 하시거나 keydown 이벤트에서 isComposing(조합중)인지 아닌지 확인해서 조합중이 아닐때 addTodo 할 수도 있어요 아래 링크 참고부탁드립니당
Comment on lines
+57
to
+81
| function minusWeek() { | ||
| const currentDate = new Date(todoDate.value); | ||
| currentDate.setDate(currentDate.getDate() - 7); | ||
| formatChangeDate(currentDate); | ||
| } | ||
|
|
||
| function plusWeek() { | ||
| const currentDate = new Date(todoDate.value); | ||
| currentDate.setDate(currentDate.getDate() + 7); | ||
| formatChangeDate(currentDate); | ||
| } | ||
|
|
||
| // 3) 이전 날짜 / 다음 날짜 | ||
| function minusDay() { | ||
| const currentDate = new Date(todoDate.value); | ||
| currentDate.setDate(currentDate.getDate() - 1); | ||
| formatChangeDate(currentDate); | ||
| } | ||
|
|
||
| function plusDay() { | ||
| const currentDate = new Date(todoDate.value); | ||
| currentDate.setDate(currentDate.getDate() + 1); | ||
| formatChangeDate(currentDate); | ||
| } | ||
|
|
There was a problem hiding this comment.
비슷한 구조의 함수가 반복되는 것 같아서 하나의 함수에 인자만 다르게 전달하는 방법도 있을 것 같아요!
Suggested change
| function minusWeek() { | |
| const currentDate = new Date(todoDate.value); | |
| currentDate.setDate(currentDate.getDate() - 7); | |
| formatChangeDate(currentDate); | |
| } | |
| function plusWeek() { | |
| const currentDate = new Date(todoDate.value); | |
| currentDate.setDate(currentDate.getDate() + 7); | |
| formatChangeDate(currentDate); | |
| } | |
| // 3) 이전 날짜 / 다음 날짜 | |
| function minusDay() { | |
| const currentDate = new Date(todoDate.value); | |
| currentDate.setDate(currentDate.getDate() - 1); | |
| formatChangeDate(currentDate); | |
| } | |
| function plusDay() { | |
| const currentDate = new Date(todoDate.value); | |
| currentDate.setDate(currentDate.getDate() + 1); | |
| formatChangeDate(currentDate); | |
| } | |
| `function changeDate(days) { | |
| const currentDate = new Date(todoDate.value); | |
| currentDate.setDate(currentDate.getDate() + days); | |
| formatChangeDate(currentDate); } | |
| prev7.addEventListener("click", () => changeDate(-7)); | |
| next7.addEventListener("click", () => changeDate(+7)); | |
| prev1.addEventListener("click", () => changeDate(-1)); | |
| next1.addEventListener("click", () => changeDate(+1));` | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
느낌점:
교양 수업 중 HTML/CSS/JS에 대해 설명하는 수업을 들었던 점이 이번 To-Do list을 만드는데 큰 도움이 되었습니다. 배운 내용을 토대로 전체 구조를 작성하고 CSS로의 디자인과 JS을 이용하여 기능을 구현하였습니다. 이번 과제에서 가장 어려웠던 부분은 To-Do을 작성하고 등록하는 과정을 코드 작성하기 가장 어려웠습니다. To-Do을 입력하면 화면에 해당 입력값을 나타내야 하고 등록했을 때 To-Do 갯수를 나타내는 등 부가적인 요소들도 동시에 연결하는 과정이 가장 어려웠었습니다.
배포링크
Review Questions
DOM(Document Object) :
// 버블링 동작 (false 생략 해도됨)element.addEventListener('click', (e) => { ... }, false);// 캡처링 동작element.addEventListener('click', (e) => { ... }, true);element.addEventListener('click', (e) => { ... }, {capture: true});(캡처링 단계 : 이벤트가 최상위 조상부터 아래로 전파 / 타깃 단계 : 이벤트가 타깃 요소에 도착 / 버블링 단계 : 다시 상위로 이벤트 전파)
클로저 :
스코프 :
참고:
DOM
이벤트 흐름 제어
클로저&스코프