1111
1212const React = require ( 'react' ) ;
1313const ReactDOM = require ( 'react-dom' ) ;
14- const findDOMNode =
15- ReactDOM . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED . findDOMNode ;
1614const StrictMode = React . StrictMode ;
1715
1816describe ( 'findDOMNode' , ( ) => {
17+ // @gate www && !disableLegacyMode
1918 it ( 'findDOMNode should return null if passed null' , ( ) => {
20- expect ( findDOMNode ( null ) ) . toBe ( null ) ;
19+ expect ( ReactDOM . findDOMNode ( null ) ) . toBe ( null ) ;
2120 } ) ;
2221
23- // @gate !disableLegacyMode
22+ // @gate www && !disableLegacyMode
2423 it ( 'findDOMNode should find dom element' , ( ) => {
2524 class MyNode extends React . Component {
2625 render ( ) {
@@ -34,13 +33,13 @@ describe('findDOMNode', () => {
3433
3534 const container = document . createElement ( 'div' ) ;
3635 const myNode = ReactDOM . render ( < MyNode /> , container ) ;
37- const myDiv = findDOMNode ( myNode ) ;
38- const mySameDiv = findDOMNode ( myDiv ) ;
36+ const myDiv = ReactDOM . findDOMNode ( myNode ) ;
37+ const mySameDiv = ReactDOM . findDOMNode ( myDiv ) ;
3938 expect ( myDiv . tagName ) . toBe ( 'DIV' ) ;
4039 expect ( mySameDiv ) . toBe ( myDiv ) ;
4140 } ) ;
4241
43- // @gate !disableLegacyMode
42+ // @gate www && !disableLegacyMode
4443 it ( 'findDOMNode should find dom element after an update from null' , ( ) => {
4544 function Bar ( { flag} ) {
4645 if ( flag ) {
@@ -57,23 +56,24 @@ describe('findDOMNode', () => {
5756 const container = document . createElement ( 'div' ) ;
5857
5958 const myNodeA = ReactDOM . render ( < MyNode /> , container ) ;
60- const a = findDOMNode ( myNodeA ) ;
59+ const a = ReactDOM . findDOMNode ( myNodeA ) ;
6160 expect ( a ) . toBe ( null ) ;
6261
6362 const myNodeB = ReactDOM . render ( < MyNode flag = { true } /> , container ) ;
6463 expect ( myNodeA === myNodeB ) . toBe ( true ) ;
6564
66- const b = findDOMNode ( myNodeB ) ;
65+ const b = ReactDOM . findDOMNode ( myNodeB ) ;
6766 expect ( b . tagName ) . toBe ( 'SPAN' ) ;
6867 } ) ;
6968
69+ // @gate www && !disableLegacyMode
7070 it ( 'findDOMNode should reject random objects' , ( ) => {
7171 expect ( function ( ) {
72- findDOMNode ( { foo : 'bar' } ) ;
72+ ReactDOM . findDOMNode ( { foo : 'bar' } ) ;
7373 } ) . toThrowError ( 'Argument appears to not be a ReactComponent. Keys: foo' ) ;
7474 } ) ;
7575
76- // @gate !disableLegacyMode
76+ // @gate www && !disableLegacyMode
7777 it ( 'findDOMNode should reject unmounted objects with render func' , ( ) => {
7878 class Foo extends React . Component {
7979 render ( ) {
@@ -85,16 +85,16 @@ describe('findDOMNode', () => {
8585 const inst = ReactDOM . render ( < Foo /> , container ) ;
8686 ReactDOM . unmountComponentAtNode ( container ) ;
8787
88- expect ( ( ) => findDOMNode ( inst ) ) . toThrowError (
88+ expect ( ( ) => ReactDOM . findDOMNode ( inst ) ) . toThrowError (
8989 'Unable to find node on an unmounted component.' ,
9090 ) ;
9191 } ) ;
9292
93- // @gate !disableLegacyMode
93+ // @gate www && !disableLegacyMode
9494 it ( 'findDOMNode should not throw an error when called within a component that is not mounted' , ( ) => {
9595 class Bar extends React . Component {
9696 UNSAFE_componentWillMount ( ) {
97- expect ( findDOMNode ( this ) ) . toBeNull ( ) ;
97+ expect ( ReactDOM . findDOMNode ( this ) ) . toBeNull ( ) ;
9898 }
9999
100100 render ( ) {
@@ -107,7 +107,7 @@ describe('findDOMNode', () => {
107107 } ) . not . toThrow ( ) ;
108108 } ) ;
109109
110- // @gate !disableLegacyMode
110+ // @gate www && !disableLegacyMode
111111 it ( 'findDOMNode should warn if used to find a host component inside StrictMode' , ( ) => {
112112 let parent = undefined ;
113113 let child = undefined ;
@@ -129,7 +129,7 @@ describe('findDOMNode', () => {
129129 ) ;
130130
131131 let match ;
132- expect ( ( ) => ( match = findDOMNode ( parent ) ) ) . toErrorDev ( [
132+ expect ( ( ) => ( match = ReactDOM . findDOMNode ( parent ) ) ) . toErrorDev ( [
133133 'Warning: findDOMNode is deprecated in StrictMode. ' +
134134 'findDOMNode was passed an instance of ContainsStrictModeChild which renders StrictMode children. ' +
135135 'Instead, add a ref directly to the element you want to reference. ' +
@@ -141,7 +141,7 @@ describe('findDOMNode', () => {
141141 expect ( match ) . toBe ( child ) ;
142142 } ) ;
143143
144- // @gate !disableLegacyMode
144+ // @gate www && !disableLegacyMode
145145 it ( 'findDOMNode should warn if passed a component that is inside StrictMode' , ( ) => {
146146 let parent = undefined ;
147147 let child = undefined ;
@@ -162,7 +162,7 @@ describe('findDOMNode', () => {
162162 ) ;
163163
164164 let match ;
165- expect ( ( ) => ( match = findDOMNode ( parent ) ) ) . toErrorDev ( [
165+ expect ( ( ) => ( match = ReactDOM . findDOMNode ( parent ) ) ) . toErrorDev ( [
166166 'Warning: findDOMNode is deprecated in StrictMode. ' +
167167 'findDOMNode was passed an instance of IsInStrictMode which is inside StrictMode. ' +
168168 'Instead, add a ref directly to the element you want to reference. ' +
0 commit comments