Browse Source

fix: list supports multiple children (without container)

gh-pages
Michael Shanks 6 years ago
parent
commit
f4701f98a5
  1. 41
      packages/client/src/render/attachChildren.js

41
packages/client/src/render/attachChildren.js

@ -30,34 +30,33 @@ export const attachChildren = initialiseOpts => (htmlElement, options) => {
} }
} }
const contextArray = Array.isArray(context) ? context : [context]
const childNodes = [] const childNodes = []
for (let childProps of treeNode.props._children) {
const { componentName, libName } = splitName(childProps._component)
if (!componentName || !libName) return for (let context of contextArray) {
for (let childProps of treeNode.props._children) {
const { componentName, libName } = splitName(childProps._component)
const ComponentConstructor = componentLibraries[libName][componentName] if (!componentName || !libName) return
const prepareNodes = ctx => { const ComponentConstructor = componentLibraries[libName][componentName]
const childNodesThisIteration = prepareRenderComponent({
props: childProps,
parentNode: treeNode,
ComponentConstructor,
htmlElement,
anchor,
context: ctx,
})
for (let childNode of childNodesThisIteration) { const prepareNodes = ctx => {
childNodes.push(childNode) const childNodesThisIteration = prepareRenderComponent({
} props: childProps,
} parentNode: treeNode,
ComponentConstructor,
htmlElement,
anchor,
context: ctx,
})
if (Array.isArray(context)) { for (let childNode of childNodesThisIteration) {
for (let singleCtx of context) { childNodes.push(childNode)
prepareNodes(singleCtx) }
} }
} else {
prepareNodes(context) prepareNodes(context)
} }
} }

Loading…
Cancel
Save