@@ -157,6 +157,14 @@ function ensureListeningTo(rootContainerElement, registrationName) {
157157 listenTo ( registrationName , doc ) ;
158158}
159159
160+ function getOwnerDocumentFromRootContainer (
161+ rootContainerElement : Element | Document ,
162+ ) : Document {
163+ return rootContainerElement . nodeType === DOCUMENT_NODE
164+ ? ( rootContainerElement : any )
165+ : rootContainerElement . ownerDocument ;
166+ }
167+
160168// There are so many media events, it makes sense to just
161169// maintain a list rather than create a `trapBubbledEvent` for each
162170var mediaEvents = {
@@ -296,10 +304,9 @@ var ReactDOMFiberComponent = {
296304 ) : Element {
297305 // We create tags in the namespace of their parent container, except HTML
298306 // tags get no namespace.
299- var ownerDocument : Document = rootContainerElement . nodeType ===
300- DOCUMENT_NODE
301- ? ( rootContainerElement : any )
302- : rootContainerElement . ownerDocument ;
307+ var ownerDocument : Document = getOwnerDocumentFromRootContainer (
308+ rootContainerElement ,
309+ ) ;
303310 var domElement : Element ;
304311 var namespaceURI = parentNamespace ;
305312 if ( namespaceURI === HTML_NAMESPACE ) {
@@ -362,6 +369,12 @@ var ReactDOMFiberComponent = {
362369 return domElement ;
363370 } ,
364371
372+ createTextNode ( text : string , rootContainerElement : Element | Document ) : Text {
373+ return getOwnerDocumentFromRootContainer (
374+ rootContainerElement ,
375+ ) . createTextNode ( text ) ;
376+ } ,
377+
365378 setInitialProperties (
366379 domElement : Element ,
367380 tag : string ,
0 commit comments