@@ -13,7 +13,6 @@ import {
13
13
} from '../events/EventRegistry' ;
14
14
15
15
import { canUseDOM } from 'shared/ExecutionEnvironment' ;
16
- import invariant from 'shared/invariant' ;
17
16
18
17
import {
19
18
getValueForAttribute ,
@@ -66,6 +65,7 @@ import {
66
65
DOCUMENT_NODE ,
67
66
ELEMENT_NODE ,
68
67
COMMENT_NODE ,
68
+ DOCUMENT_FRAGMENT_NODE ,
69
69
} from '../shared/HTMLNodeType' ;
70
70
import isCustomComponent from '../shared/isCustomComponent' ;
71
71
import possibleStandardNames from '../shared/possibleStandardNames' ;
@@ -266,15 +266,19 @@ export function ensureListeningTo(
266
266
rootContainerInstance . nodeType === COMMENT_NODE
267
267
? rootContainerInstance . parentNode
268
268
: rootContainerInstance ;
269
- // Containers should only ever be element nodes. We do not
270
- // want to register events to document fragments or documents
271
- // with the modern plugin event system.
272
- invariant (
273
- rootContainerElement != null &&
274
- rootContainerElement . nodeType === ELEMENT_NODE ,
275
- 'ensureListeningTo(): received a container that was not an element node. ' +
276
- 'This is likely a bug in React.' ,
277
- ) ;
269
+ if ( __DEV__ ) {
270
+ if (
271
+ rootContainerElement == null ||
272
+ ( rootContainerElement . nodeType !== ELEMENT_NODE &&
273
+ // This is to support rendering into a ShadowRoot:
274
+ rootContainerElement . nodeType !== DOCUMENT_FRAGMENT_NODE )
275
+ ) {
276
+ console . error (
277
+ 'ensureListeningTo(): received a container that was not an element node. ' +
278
+ 'This is likely a bug in React. Please file an issue.' ,
279
+ ) ;
280
+ }
281
+ }
278
282
listenToReactEvent (
279
283
reactPropEvent ,
280
284
( ( rootContainerElement : any ) : Element ) ,
0 commit comments