@pronto-tools-and-more/components-renderer 5.3.3 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/components-renderer",
3
- "version": "5.3.3",
3
+ "version": "5.5.0",
4
4
  "description": "",
5
5
  "main": "src/componentsRendererMain.js",
6
6
  "type": "module",
@@ -10,19 +10,29 @@ export const renderElement = (element) => {
10
10
  };
11
11
  }
12
12
  if (element.tag) {
13
+ if (typeof element.tag === "function") {
14
+ const vnode = element.tag({
15
+ ...element.props,
16
+ });
17
+ const rendered = renderElement(vnode);
18
+ return rendered;
19
+ }
13
20
  const hasComplexChildren = HasComplexChildren.hasComplexChildren(element);
14
21
  const renderedChildren = hasComplexChildren
15
22
  ? element.children.map(renderElement)
16
23
  : [];
17
24
  const content = hasComplexChildren ? "" : element.children[0] || "";
18
- const className =
19
- element.props && element.props.className
20
- ? element.props.className
21
- : undefined;
25
+ const props = element.props ? element.props : {};
26
+ const { className, ...rest } = props;
27
+ let attributes;
28
+ if (Object.keys(rest).length > 0) {
29
+ attributes = rest;
30
+ }
22
31
  return CreateFakeSection.createFakeSection([
23
32
  {
24
33
  type: "html",
25
34
  tag: element.tag,
35
+ attributes,
26
36
  class: className,
27
37
  content,
28
38
  },