处理Element

  1. const processElement = (
  2. n1,
  3. n2,
  4. container,
  5. anchor,
  6. parentComponent,
  7. parentSuspense,
  8. isSVG,
  9. optimized
  10. ) => {
  11. isSVG = isSVG || n2.type === 'svg'
  12. if (n1 == null) {
  13. mountElement(
  14. n2,
  15. container,
  16. anchor,
  17. parentComponent,
  18. parentSuspense,
  19. isSVG,
  20. optimized
  21. )
  22. } else {
  23. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, optimized)
  24. }
  25. }

总结:

该方法主要是做了2件事情:

  1. 不存在旧节点,挂载
  2. 存在旧节点,更新,执行 patchElement