Evan You 9 tahun lalu
induk
melakukan
dc00590bc5
1 mengubah file dengan 4 tambahan dan 0 penghapusan
  1. 4 0
      src/core/vdom/helpers/normalize-children.js

+ 4 - 0
src/core/vdom/helpers/normalize-children.js

@@ -52,6 +52,9 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
       res.push.apply(res, normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`))
     } else if (isPrimitive(c)) {
       if (isTextNode(last)) {
+        // merge adjacent text nodes
+        // this is necessary for SSR hydration because text nodes are
+        // essentially merged when rendered to HTML strings
         (last: any).text += String(c)
       } else if (c !== '') {
         // convert primitive to vnode
@@ -59,6 +62,7 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
       }
     } else {
       if (isTextNode(c) && isTextNode(last)) {
+        // merge adjacent text nodes
         res[res.length - 1] = createTextVNode(last.text + c.text)
       } else {
         // default key for nested array children (likely generated by v-for)