Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed test bug #1

Merged
merged 1 commit into from
Aug 27, 2022
Merged

fixed test bug #1

merged 1 commit into from
Aug 27, 2022

Conversation

miniflycn
Copy link

修改jest测试,想想为啥这样改就可以呢?

@icebox1234
Copy link

查询了相关的文档,attachTo的作用是将特定的组件挂在指定的文档元素中。之前没有使用attachTo时,HelloWorld这个组件没有挂载到文档中,导致了template中的HTMLElement没有出现在document中,有点像document.createFragment创建了dom片段,但是没有真正的挂在到document中。在这种情况下,针对于HelloWorld中元素设置的事件代理其实就相当于对页面中一个不存在的元素进行事件代理的设置,所以click事件的addEventListener的回调是不会响应的。

@icebox1234 icebox1234 merged commit 0cc7096 into icebox1234-FE-course-2022:main Aug 27, 2022
@miniflycn
Copy link
Author

赞👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants