@@ -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 ,
@@ -257,7 +256,7 @@ if (__DEV__) {
257
256
}
258
257
259
258
export function ensureListeningTo (
260
- rootContainerInstance : Element | Node | ShadowRoot ,
259
+ rootContainerInstance : Element | Node ,
261
260
reactPropEvent : string ,
262
261
targetElement : Element | null ,
263
262
) : void {
@@ -267,18 +266,19 @@ export function ensureListeningTo(
267
266
rootContainerInstance . nodeType === COMMENT_NODE
268
267
? rootContainerInstance . parentNode
269
268
: rootContainerInstance ;
270
- // Containers should only ever be element nodes. We do not
271
- // want to register events to document fragments or documents
272
- // with the modern plugin event system.
273
- invariant (
274
- rootContainerElement != null &&
275
- ( rootContainerElement . nodeType === ELEMENT_NODE ||
276
- ( rootContainerElement . nodeType === DOCUMENT_FRAGMENT_NODE &&
277
- // $FlowFixMe GH issue #8457
278
- ( ( rootContainerElement : any ) : ShadowRoot ) . mode ) ) ,
279
- 'ensureListeningTo(): received a container that was not an element node. ' +
280
- 'This is likely a bug in React.' ,
281
- ) ;
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
+ }
282
282
listenToReactEvent (
283
283
reactPropEvent ,
284
284
( ( rootContainerElement : any ) : Element ) ,
@@ -287,7 +287,7 @@ export function ensureListeningTo(
287
287
}
288
288
289
289
function getOwnerDocumentFromRootContainer (
290
- rootContainerElement : Element | Document | ShadowRoot ,
290
+ rootContainerElement : Element | Document ,
291
291
) : Document {
292
292
return rootContainerElement . nodeType === DOCUMENT_NODE
293
293
? ( rootContainerElement : any )
@@ -312,7 +312,7 @@ export function trapClickOnNonInteractiveElement(node: HTMLElement) {
312
312
function setInitialDOMProperties (
313
313
tag : string ,
314
314
domElement : Element ,
315
- rootContainerElement : Element | Document | ShadowRoot ,
315
+ rootContainerElement : Element | Document ,
316
316
nextProps : Object ,
317
317
isCustomComponentTag : boolean ,
318
318
) : void {
@@ -397,7 +397,7 @@ function updateDOMProperties(
397
397
export function createElement (
398
398
type : string ,
399
399
props : Object ,
400
- rootContainerElement : Element | Document | ShadowRoot ,
400
+ rootContainerElement : Element | Document ,
401
401
parentNamespace : string ,
402
402
) : Element {
403
403
let isCustomComponentTag ;
@@ -503,7 +503,7 @@ export function createElement(
503
503
504
504
export function createTextNode (
505
505
text : string ,
506
- rootContainerElement : Element | Document | ShadowRoot ,
506
+ rootContainerElement : Element | Document ,
507
507
) : Text {
508
508
return getOwnerDocumentFromRootContainer ( rootContainerElement ) . createTextNode (
509
509
text ,
@@ -514,7 +514,7 @@ export function setInitialProperties(
514
514
domElement : Element ,
515
515
tag : string ,
516
516
rawProps : Object ,
517
- rootContainerElement : Element | Document | ShadowRoot ,
517
+ rootContainerElement : Element | Document ,
518
518
) : void {
519
519
const isCustomComponentTag = isCustomComponent ( tag , rawProps ) ;
520
520
if ( __DEV__ ) {
@@ -649,7 +649,7 @@ export function diffProperties(
649
649
tag : string ,
650
650
lastRawProps : Object ,
651
651
nextRawProps : Object ,
652
- rootContainerElement : Element | Document | ShadowRoot ,
652
+ rootContainerElement : Element | Document ,
653
653
) : null | Array < mixed > {
654
654
if ( __DEV__ ) {
655
655
validatePropertiesInDevelopment ( tag , nextRawProps ) ;
@@ -914,7 +914,7 @@ export function diffHydratedProperties(
914
914
tag : string ,
915
915
rawProps : Object ,
916
916
parentNamespace : string ,
917
- rootContainerElement : Element | Document | ShadowRoot ,
917
+ rootContainerElement : Element | Document ,
918
918
) : null | Array < mixed > {
919
919
let isCustomComponentTag ;
920
920
let extraAttributeNames : Set < string > ;
@@ -1213,7 +1213,7 @@ export function warnForUnmatchedText(textNode: Text, text: string) {
1213
1213
}
1214
1214
1215
1215
export function warnForDeletedHydratableElement (
1216
- parentNode : Element | Document | ShadowRoot ,
1216
+ parentNode : Element | Document ,
1217
1217
child : Element ,
1218
1218
) {
1219
1219
if ( __DEV__ ) {
@@ -1230,7 +1230,7 @@ export function warnForDeletedHydratableElement(
1230
1230
}
1231
1231
1232
1232
export function warnForDeletedHydratableText (
1233
- parentNode : Element | Document | ShadowRoot ,
1233
+ parentNode : Element | Document ,
1234
1234
child : Text ,
1235
1235
) {
1236
1236
if ( __DEV__ ) {
@@ -1247,7 +1247,7 @@ export function warnForDeletedHydratableText(
1247
1247
}
1248
1248
1249
1249
export function warnForInsertedHydratedElement (
1250
- parentNode : Element | Document | ShadowRoot ,
1250
+ parentNode : Element | Document ,
1251
1251
tag : string ,
1252
1252
props : Object ,
1253
1253
) {
@@ -1265,7 +1265,7 @@ export function warnForInsertedHydratedElement(
1265
1265
}
1266
1266
1267
1267
export function warnForInsertedHydratedText (
1268
- parentNode : Element | Document | ShadowRoot ,
1268
+ parentNode : Element | Document ,
1269
1269
text : string ,
1270
1270
) {
1271
1271
if ( __DEV__ ) {
0 commit comments