enzyme-adapter-react-16
Advanced tools
Comparing version 1.15.3 to 1.15.4
{ | ||
"name": "enzyme-adapter-react-16", | ||
"version": "1.15.3", | ||
"version": "1.15.4", | ||
"description": "JavaScript Testing utilities for React", | ||
@@ -63,8 +63,8 @@ "homepage": "https://enzymejs.github.io/enzyme/", | ||
"enzyme": "^3.0.0", | ||
"eslint": "^7.6.0", | ||
"eslint": "^7.7.0", | ||
"eslint-config-airbnb": "^18.2.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-react": "^7.20.5", | ||
"eslint-plugin-react-hooks": "^4.0.8", | ||
"eslint-plugin-react": "^7.20.6", | ||
"eslint-plugin-react-hooks": "^4.1.0", | ||
"in-publish": "^2.0.1", | ||
@@ -71,0 +71,0 @@ "rimraf": "^2.7.1", |
@@ -123,16 +123,40 @@ /* eslint no-use-before-define: 0 */ | ||
function checkIsSuspenseAndCloneElement(el, { suspenseFallback }) { | ||
if (!isSuspense(el)) { | ||
return el; | ||
function transformSuspense(renderedEl, prerenderEl, { suspenseFallback }) { | ||
if (!isSuspense(renderedEl)) { | ||
return renderedEl; | ||
} | ||
let { children } = el.props; | ||
let { children } = renderedEl.props; | ||
if (suspenseFallback) { | ||
const { fallback } = el.props; | ||
const { fallback } = renderedEl.props; | ||
children = replaceLazyWithFallback(children, fallback); | ||
} | ||
const FakeSuspenseWrapper = (props) => React.createElement(el.type, { ...el.props, ...props }, children); | ||
return React.createElement(FakeSuspenseWrapper, null, children); | ||
if (isStateful(prerenderEl.type)) { | ||
class FakeSuspense extends prerenderEl.type { | ||
render() { | ||
return React.createElement( | ||
prerenderEl.type, | ||
{ ...prerenderEl.props, ...this.props }, | ||
children, | ||
); | ||
} | ||
} | ||
return React.createElement(FakeSuspense, null, children); | ||
} | ||
return React.createElement( | ||
// eslint-disable-next-line prefer-arrow-callback | ||
function FakeSuspense(props) { | ||
return React.createElement( | ||
renderedEl.type, | ||
{ ...renderedEl.props, ...props }, | ||
children, | ||
); | ||
}, | ||
null, | ||
children, | ||
); | ||
} | ||
@@ -613,3 +637,3 @@ | ||
if (is166 && typeIsExisted) { | ||
const clonedEl = checkIsSuspenseAndCloneElement(renderedEl, { suspenseFallback }); | ||
const clonedEl = transformSuspense(renderedEl, elConfig, { suspenseFallback }); | ||
@@ -657,3 +681,3 @@ const elementIsChanged = clonedEl.type !== renderedEl.type; | ||
renderedEl = checkIsSuspenseAndCloneElement(renderedEl, { suspenseFallback }); | ||
renderedEl = transformSuspense(renderedEl, renderedEl, { suspenseFallback }); | ||
const { type: Component } = renderedEl; | ||
@@ -660,0 +684,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273370
2694