pomber / didact

A DIY guide to build your own React
https://pomb.us/build-your-own-react/
6.29k stars 531 forks source link

updateDom in createDom function #40

Open Kuuga46 opened 2 years ago

Kuuga46 commented 2 years ago

I don't understand why we excute 'updateDom' in the function 'createDom'.It seems that we would change the dom before 'commit',and that should not happen in 'performUnitOfWork' image

Kuuga46 commented 2 years ago

I found the reason: image

image

ZhaoTim commented 2 years ago

updateDom方法貌似只是用来处理dom元素的一些attributes以及一些事件绑定,创建了dom以后不就应该即可绑定属性、事件吗?而且updateDom里的逻辑也不存在把dom挂载到页面的行为,应该没问题吧?