javascript-tutorial / javascript-tutorial/ko.javascript.info
[Bug report] 이벤트 버블링, 캡처링 부분 수정 요청 드립니다!
- Dominant language
- HTML
- Stars
- 2k
- Forks
- 852
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug report
안녕하세요. 항상 공부하는데에 유용하게 사용하고 있습니다!! JS를 열심히 공부하고 있는 학생입니다. 이렇게 이슈를 남겨도 되는지 모르겠는데 한번 남겨 봅니다.
https://ko.javascript.info/bubbling-and-capturing

공부를 하던 도중 이 부분이 설명이 이상한 것 같아 이슈를 남겨봅니다. 2번을 보시면 p가 타겟 단계이고, 캡처링과 버블링 둘다에 리스너를 설정했기 때문에 두 번 호출 됩니다라고 적혀있습니다.
그러면 target phase 에서도 캡처링 이벤트가 먼저 실행되고 버블링 이벤트가 후에 실행될 것처럼 적혀있어요. 그런데 제가 알기로는 캡처링, 버블링은 target phase가 아닐 때, 어느 phase에서 실행될 것인지를 결정하는 것으로 알고 있습니다.
즉, 캡쳐링과 버블링 둘 다에 리스너를 설정했기 때문에 두번 호출 되는 것이 아니라, 단순히 event를 두번 설정했기 때문에 두번 호출된다고 적는 것이 맞지 않나 싶어요!
## 환경
Windows 10, Chrome
## 재연할 수 있는 방법
```html
Document
div {
width: 200px;
height: 200px;
background-color: aqua;
}
div!!
const html = document.querySelector('html');
const body = document.querySelector('body');
const div = document.querySelector('div');
div.addEventListener('click', (e) => {
console.log('div!!')
});
div.addEventListener('click', (e) => {
console.log('capture div!!')
}, true);
body.addEventListener('click', () => {
console.log('bubble body!')
});
body.addEventListener('click', (e) => {
console.log('capture body!');
}, true);
html.addEventListener('click', () => {
console.log('bubble html!');
});
html.addEventListener('click', () => {
console.log('capture html!');
}, true)
```
이렇게 실행 했을 때, html과 body 부분은 capture부분이 먼저 실행되고, bubble 부분이 실행되는 것을 확인할 수 있습니다. 그런데 div 부분은 capture 먼저, bubble 먼저가 아닌 단순히 event가 설정된 순서대로 실행되는 것을 확인할 수 있어요.

Contributor guide
Research direction
Start with the linked bubbling-and-capturing tutorial section and run the supplied HTML example to verify the target-phase behavior. Update the explanation so it accurately describes why both listeners run on the target, then recheck the surrounding event-order example for consistency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100