(children, nestedIndex)
| 2148 | } |
| 2149 | |
| 2150 | function normalizeArrayChildren(children, nestedIndex) { |
| 2151 | var res = []; |
| 2152 | var i, c, lastIndex, last; |
| 2153 | for (i = 0; i < children.length; i++) { |
| 2154 | c = children[i]; |
| 2155 | if (isUndef(c) || typeof c === "boolean") { |
| 2156 | continue; |
| 2157 | } |
| 2158 | lastIndex = res.length - 1; |
| 2159 | last = res[lastIndex]; |
| 2160 | // nested |
| 2161 | if (Array.isArray(c)) { |
| 2162 | if (c.length > 0) { |
| 2163 | c = normalizeArrayChildren(c, (nestedIndex || "") + "_" + i); |
| 2164 | // merge adjacent text nodes |
| 2165 | if (isTextNode(c[0]) && isTextNode(last)) { |
| 2166 | res[lastIndex] = createTextVNode(last.text + c[0].text); |
| 2167 | c.shift(); |
| 2168 | } |
| 2169 | res.push.apply(res, c); |
| 2170 | } |
| 2171 | } else if (isPrimitive(c)) { |
| 2172 | if (isTextNode(last)) { |
| 2173 | // merge adjacent text nodes |
| 2174 | // this is necessary for SSR hydration because text nodes are |
| 2175 | // essentially merged when rendered to HTML strings |
| 2176 | res[lastIndex] = createTextVNode(last.text + c); |
| 2177 | } else if (c !== "") { |
| 2178 | // convert primitive to vnode |
| 2179 | res.push(createTextVNode(c)); |
| 2180 | } |
| 2181 | } else { |
| 2182 | if (isTextNode(c) && isTextNode(last)) { |
| 2183 | // merge adjacent text nodes |
| 2184 | res[lastIndex] = createTextVNode(last.text + c.text); |
| 2185 | } else { |
| 2186 | // default key for nested array children (likely generated by v-for) |
| 2187 | if (isTrue(children._isVList) && isDef(c.tag) && isUndef(c.key) && isDef(nestedIndex)) { |
| 2188 | c.key = "__vlist" + nestedIndex + "_" + i + "__"; |
| 2189 | } |
| 2190 | res.push(c); |
| 2191 | } |
| 2192 | } |
| 2193 | } |
| 2194 | return res; |
| 2195 | } |
| 2196 | |
| 2197 | /* */ |
| 2198 |
no test coverage detected