move to function
This commit is contained in:
parent
46e06736a8
commit
bb1ae4c4ec
|
|
@ -32,6 +32,14 @@ function isJsxComponent(component) {
|
||||||
return typeof component === 'object' && component && component.__pw_type === 'jsx';
|
return typeof component === 'object' && component && component.__pw_type === 'jsx';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} type
|
||||||
|
* @returns type is Playwright's mock JSX.Fragment
|
||||||
|
*/
|
||||||
|
function isJsxFragment(type) {
|
||||||
|
return typeof type === 'object' && type?.__pw_jsx_fragment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns the Playwright representation of JSX (see jsx-runtime.js) into React.createElement calls.
|
* Turns the Playwright representation of JSX (see jsx-runtime.js) into React.createElement calls.
|
||||||
* @param {any} value
|
* @param {any} value
|
||||||
|
|
@ -41,7 +49,7 @@ function __pwRender(value) {
|
||||||
if (isJsxComponent(v)) {
|
if (isJsxComponent(v)) {
|
||||||
const component = v;
|
const component = v;
|
||||||
let type = component.type;
|
let type = component.type;
|
||||||
if (type && type.__pw_jsx_fragment)
|
if (isJsxFragment(type))
|
||||||
type = __pwReact.Fragment;
|
type = __pwReact.Fragment;
|
||||||
const props = component.props ? __pwRender(component.props) : {};
|
const props = component.props ? __pwRender(component.props) : {};
|
||||||
const key = component.key ? __pwRender(component.key) : undefined;
|
const key = component.key ? __pwRender(component.key) : undefined;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue