@@ -13,7 +13,6 @@ import {
1313} from '../events/EventRegistry' ;
1414
1515import { canUseDOM } from 'shared/ExecutionEnvironment' ;
16- import invariant from 'shared/invariant' ;
1716
1817import {
1918 getValueForAttribute ,
@@ -66,6 +65,7 @@ import {
6665 DOCUMENT_NODE ,
6766 ELEMENT_NODE ,
6867 COMMENT_NODE ,
68+ DOCUMENT_FRAGMENT_NODE ,
6969} from '../shared/HTMLNodeType' ;
7070import isCustomComponent from '../shared/isCustomComponent' ;
7171import possibleStandardNames from '../shared/possibleStandardNames' ;
@@ -266,15 +266,19 @@ export function ensureListeningTo(
266266 rootContainerInstance . nodeType === COMMENT_NODE
267267 ? rootContainerInstance . parentNode
268268 : 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+ }
278282 listenToReactEvent (
279283 reactPropEvent ,
280284 ( ( rootContainerElement : any ) : Element ) ,
0 commit comments