Checkpoint · code-edit

bubbling 與 delegation

只驗證本主題責任,不偷渡其他答案。

Checkpoint 要做什麼

只驗證本主題責任,不偷渡其他答案。

本主題檔案:files/main.js

定位:先確認 click 是否 bubbles 到 container。

本階段驗收

頁面不會替你修改檔案;請在實作檔完成後重新整理確認。

目前要處理

container 有兩個按鈕但沒有 child listener。

預期看到

listenerCount=1、handledCount=2、lastTarget 為第二個按鈕。

container.addEventListener('click', e => e.target.closest('button'))。

檔案清單

只在本階段資料夾內操作,避免改到其他章節。

證據:listenerCount=1、handledCount=2、currentTarget=container

前往 Solution →