处理注释

  1. const processCommentNode = (n1, n2, container, anchor) => {
  2. if (n1 == null) {
  3. hostInsert(
  4. (n2.el = hostCreateComment(n2.children || '')),
  5. container,
  6. anchor
  7. )
  8. } else {
  9. // there's no support for dynamic comments
  10. n2.el = n1.el
  11. }
  12. }

总结:

  1. 新增:创建一个注释节点到container,指向新节点 n2el
  2. 更新:新节点的 el 指向老节点的 el