1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

fix: list supports multiple children (without container)

This commit is contained in:
Michael Shanks 2020-07-06 14:21:55 +01:00
parent 6cfc48d2a7
commit 51054786c2

View file

@ -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,
})
for (let childNode of childNodesThisIteration) {
childNodes.push(childNode)
}
} }
}
if (Array.isArray(context)) {
for (let singleCtx of context) {
prepareNodes(singleCtx)
}
} else {
prepareNodes(context) prepareNodes(context)
} }
} }