File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
packages/devextreme-react/src/core Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ describe('rendering', () => {
6262 </ TestComponent >
6363 ) ;
6464 const { container, unmount, rerender } = render (
65- component , { legacyRoot : true }
65+ component , { legacyRoot : true } ,
6666 ) ;
6767
6868 unmount ( ) ;
@@ -171,6 +171,17 @@ describe('rendering', () => {
171171 expect ( WidgetClass . mock . instances [ 1 ] ) . toEqual ( { } ) ;
172172 } ) ;
173173
174+ it ( 'clears nested option in strict mode' , ( ) => {
175+ render (
176+ < React . StrictMode >
177+ < TestComponent >
178+ < TestComponent />
179+ </ TestComponent >
180+ </ React . StrictMode > ,
181+ ) ;
182+ expect ( Widget . clearExtensions ) . toHaveBeenCalledTimes ( 4 ) ;
183+ } ) ;
184+
174185 it ( 'do not pass children to options' , ( ) => {
175186 render (
176187 < TestComponent >
@@ -185,8 +196,8 @@ describe('rendering', () => {
185196describe ( 'element attrs management' , ( ) => {
186197 it ( 'passes id, className and style to element' , ( ) => {
187198 const { container } = render (
188- < TestComponent id = "id1" className = "class1" style = { { background : 'red' } } /> , {
189- } ,
199+ < TestComponent id = "id1" className = "class1" style = { { background : 'red' } } /> ,
200+ { } ,
190201 ) ;
191202
192203 const element : HTMLElement = container . firstChild as HTMLElement ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const Widget = {
1818 off : ( event : string , handler : ( e : any ) => void ) => {
1919 eventHandlers [ event ] = eventHandlers [ event ] . filter ( ( e ) => e !== handler ) ;
2020 } ,
21+ clearExtensions : jest . fn ( ) ,
2122 dispose : jest . fn ( ) ,
2223 skipOptionsRollBack : false ,
2324} ;
@@ -36,6 +37,11 @@ class TestComponent<P = any> extends Component<P> {
3637 super . _createWidget ( element ) ;
3738 Widget . option . mockReset ( ) ;
3839 }
40+
41+ clearExtensions ( ) : void {
42+ super . clearExtensions ( ) ;
43+ Widget . clearExtensions ( ) ;
44+ }
3945}
4046class TestPortalComponent < P = any > extends TestComponent < P > {
4147 protected isPortalComponent = true ;
Original file line number Diff line number Diff line change @@ -18,6 +18,15 @@ class Component<P> extends ComponentBase<P> {
1818 this . _createExtensions ( ) ;
1919 }
2020
21+ public componentWillUnmount ( ) : void {
22+ super . componentWillUnmount ( ) ;
23+ this . clearExtensions ( ) ;
24+ }
25+
26+ public clearExtensions ( ) : void {
27+ this . _extensionCreators = [ ] ;
28+ }
29+
2130 protected renderChildren ( ) : Record < string , unknown > [ ] | null | undefined {
2231 return React . Children . map (
2332 this . props . children ,
You can’t perform that action at this time.
0 commit comments