Skip to content

Commit a891ce3

Browse files
committed
feat: 접근제한자 설정
1 parent 7a41257 commit a891ce3

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/App.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { setItem } from "./utils/storage.js";
66
import { TodoCount as TodoCnt, TodoItem } from "./types/todo.js";
77

88
export default class App {
9-
todoList: TodoList;
10-
todoCount: TodoCount;
9+
private readonly todoList: TodoList;
10+
private readonly todoCount: TodoCount;
1111

1212
constructor(
13-
protected readonly $target: HTMLElement,
14-
protected readonly initialState: TodoItem[],
15-
protected readonly initialCount: TodoCnt
13+
private readonly $target: HTMLElement,
14+
private readonly initialState: TodoItem[],
15+
private readonly initialCount: TodoCnt
1616
) {
1717
new Header(this.$target, "Todo List");
1818

@@ -27,14 +27,14 @@ export default class App {
2727
this.todoList = new TodoList(
2828
this.$target,
2929
this.initialState,
30-
(state: TodoItem[]) => this.updateCount(state)
30+
(state: TodoItem[]) => this.#updateCount(state)
3131
);
3232

3333
this.todoCount = new TodoCount(this.$target, this.initialCount);
3434
}
3535

3636
// 카운트 업데이트
37-
updateCount(todoList: TodoItem[]) {
37+
#updateCount(todoList: TodoItem[]) {
3838
const done = todoList.filter((todo) => todo.isCompleted).length;
3939
const nextState = { total: todoList.length, done };
4040
this.todoCount.setState(nextState);

src/components/Header.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default class Header {
2-
$header = document.createElement("h1");
2+
private readonly $header = document.createElement("h1");
33

44
constructor(
55
private readonly $target: HTMLElement,
@@ -9,7 +9,7 @@ export default class Header {
99
this.render();
1010
};
1111

12-
render() {
12+
private render() {
1313
this.$header.textContent = this.text;
1414
}
1515
};

src/components/TodoCount.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { TodoCount as TodoCnt } from "../types/todo.js";
22

33
export default class TodoCount {
4-
$container = document.createElement("div");
5-
state: TodoCnt;
4+
private readonly $container = document.createElement("div");
5+
private state: TodoCnt;
66

77
constructor(
88
private readonly $target: HTMLElement,
@@ -22,7 +22,7 @@ export default class TodoCount {
2222
this.render();
2323
};
2424

25-
render() {
25+
private render() {
2626
this.$container.textContent = `완료 ${this.state.done}개 / 총 ${this.state.total}개`;
2727
};
2828
}

src/components/TodoForm.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
export default class TodoForm {
3-
$form = document.createElement("form");
4-
isInit = false;
3+
private readonly $form = document.createElement("form");
4+
private isInit = false;
55

66
constructor(
77
private readonly $target: HTMLElement,
@@ -11,7 +11,7 @@ export default class TodoForm {
1111
this.render();
1212
}
1313

14-
render() {
14+
private render() {
1515
this.$form.innerHTML = `
1616
<input type="text" placeholder="할 일을 입력하세요" name="todo" />
1717
<button>추가</button>

src/components/TodoList.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TodoItem } from "../types/todo.js";
44

55
export default class TodoList {
66
state: TodoItem[] = [];
7-
$todoList = document.createElement("div");
7+
private readonly $todoList = document.createElement("div");
88

99
constructor(
1010
private readonly $target: HTMLElement,
@@ -51,7 +51,7 @@ export default class TodoList {
5151
this.render();
5252
};
5353

54-
render() {
54+
private render() {
5555
this.$todoList.innerHTML = `
5656
<ul>
5757
${this.state

0 commit comments

Comments
 (0)