@playwright/experimental-ct-react17 1.40.0-alpha-oct-27-2023 → 1.40.0-alpha-oct-29-2023

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/registerSource.mjs +15 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright/experimental-ct-react17",
3
- "version": "1.40.0-alpha-oct-27-2023",
3
+ "version": "1.40.0-alpha-oct-29-2023",
4
4
  "description": "Playwright Component Testing for React",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@playwright/experimental-ct-core": "1.40.0-alpha-oct-27-2023",
32
+ "@playwright/experimental-ct-core": "1.40.0-alpha-oct-29-2023",
33
33
  "@vitejs/plugin-react": "^4.0.0"
34
34
  },
35
35
  "bin": {
@@ -75,23 +75,27 @@ async function __pwResolveComponent(component) {
75
75
  }
76
76
 
77
77
  /**
78
- * @param {JsxComponent | JsxComponentChild} component
78
+ * @param {JsxComponentChild} child
79
79
  */
80
- function __pwRender(component) {
81
- if (!isComponent(component))
82
- return component;
80
+ function __renderChild(child) {
81
+ if (Array.isArray(child))
82
+ return child.map(grandChild => __renderChild(grandChild));
83
+ if (isComponent(child))
84
+ return __pwRender(child);
85
+ return child;
86
+ }
83
87
 
88
+ /**
89
+ * @param {JsxComponent} component
90
+ */
91
+ function __pwRender(component) {
84
92
  const componentFunc = __pwRegistry.get(component.type);
85
-
86
- return __pwReact.createElement(componentFunc || component.type, component.props, ...component.children.map(child => {
87
- if (typeof child === 'string')
88
- return child;
89
- return __pwRender(child);
90
- }).filter(child => {
93
+ const children = component.children.map(child => __renderChild(child)).filter(child => {
91
94
  if (typeof child === 'string')
92
95
  return !!child.trim();
93
96
  return true;
94
- }));
97
+ });
98
+ return __pwReact.createElement(componentFunc || component.type, component.props, children);
95
99
  }
96
100
 
97
101
  window.playwrightMount = async (component, rootElement, hooksConfig) => {