(children, options = {})
| 199 | } |
| 200 | |
| 201 | renderChildren(children, options = {}) { |
| 202 | const { |
| 203 | props = {}, |
| 204 | renderer = (component) => component.render(), |
| 205 | attributes = {}, |
| 206 | rawXML = false, |
| 207 | } = options |
| 208 | |
| 209 | children = children || this.props.children |
| 210 | |
| 211 | if (rawXML) { |
| 212 | return children |
| 213 | .map((child) => { |
| 214 | child.attributes = { ...attributes, ...child.attributes } |
| 215 | return jsonToXML(child) |
| 216 | }) |
| 217 | .join('\n') |
| 218 | } |
| 219 | |
| 220 | const sibling = children.length |
| 221 | |
| 222 | const rawComponents = filter(this.context.components, (c) => |
| 223 | c.isRawElement(), |
| 224 | ) |
| 225 | const nonRawSiblings = children.filter( |
| 226 | (child) => !find(rawComponents, (c) => c.getTagName() === child.tagName), |
| 227 | ).length |
| 228 | |
| 229 | let output = '' |
| 230 | let index = 0 |
| 231 | |
| 232 | forEach(children, (children) => { |
| 233 | const component = initComponent({ |
| 234 | name: children.tagName, |
| 235 | initialDatas: { |
| 236 | ...children, |
| 237 | attributes: { |
| 238 | ...attributes, |
| 239 | ...children.attributes, |
| 240 | }, |
| 241 | context: this.getChildContext(), |
| 242 | props: { |
| 243 | ...props, |
| 244 | first: index === 0, |
| 245 | index, |
| 246 | last: index + 1 === sibling, |
| 247 | sibling, |
| 248 | nonRawSiblings, |
| 249 | }, |
| 250 | }, |
| 251 | }) |
| 252 | |
| 253 | if (component !== null) { |
| 254 | output += renderer(component) |
| 255 | } |
| 256 | |
| 257 | index++ // eslint-disable-line no-plusplus |
| 258 | }) |
no test coverage detected