|
9 | 9 |
|
10 | 10 | import type {Instance, Container} from './ReactDOMHostConfig'; |
11 | 11 |
|
12 | | -import {isAttributeNameSafe} from '../shared/DOMProperty'; |
13 | | -import {precacheFiberNode} from './ReactDOMComponentTree'; |
| 12 | +import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext'; |
14 | 13 |
|
15 | 14 | import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals.js'; |
16 | 15 | const {Dispatcher} = ReactDOMSharedInternals; |
| 16 | +import { |
| 17 | + checkAttributeStringCoercion, |
| 18 | + checkPropStringCoercion, |
| 19 | +} from 'shared/CheckStringCoercion'; |
| 20 | + |
17 | 21 | import {DOCUMENT_NODE} from '../shared/HTMLNodeType'; |
| 22 | +import {isAttributeNameSafe} from '../shared/DOMProperty'; |
| 23 | +import {SVG_NAMESPACE} from '../shared/DOMNamespaces'; |
18 | 24 | import { |
19 | 25 | validatePreloadArguments, |
20 | 26 | validatePreinitArguments, |
21 | 27 | getValueDescriptorExpectingObjectForWarning, |
22 | 28 | getValueDescriptorExpectingEnumForWarning, |
23 | 29 | } from '../shared/ReactDOMResourceValidation'; |
| 30 | + |
| 31 | +import {precacheFiberNode} from './ReactDOMComponentTree'; |
24 | 32 | import {createHTMLElement, setInitialProperties} from './ReactDOMComponent'; |
25 | | -import { |
26 | | - checkAttributeStringCoercion, |
27 | | - checkPropStringCoercion, |
28 | | -} from 'shared/CheckStringCoercion'; |
29 | 33 | import { |
30 | 34 | getResourcesFromRoot, |
31 | 35 | isMarkedResource, |
32 | 36 | markNodeAsResource, |
33 | 37 | } from './ReactDOMComponentTree'; |
34 | | -import {SVG_NAMESPACE} from '../shared/DOMNamespaces'; |
35 | | -import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext'; |
36 | 38 |
|
37 | 39 | // The resource types we support. currently they match the form for the as argument. |
38 | 40 | // In the future this may need to change, especially when modules / scripts are supported |
@@ -414,7 +416,8 @@ function preinit(href: string, options: PreinitOptions) { |
414 | 416 | if (preloadProps) { |
415 | 417 | adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); |
416 | 418 | } |
417 | | - instance = createHTMLElement('link', stylesheetProps, resourceRoot); |
| 419 | + const ownerDocument = getDocumentFromRoot(resourceRoot); |
| 420 | + instance = createHTMLElement('link', stylesheetProps, ownerDocument); |
418 | 421 | markNodeAsResource(instance); |
419 | 422 | setInitialProperties(instance, 'link', stylesheetProps); |
420 | 423 | insertStylesheet(instance, precedence, resourceRoot); |
@@ -455,7 +458,8 @@ function preinit(href: string, options: PreinitOptions) { |
455 | 458 | if (preloadProps) { |
456 | 459 | adoptPreloadPropsForScript(scriptProps, preloadProps); |
457 | 460 | } |
458 | | - instance = createHTMLElement('script', scriptProps, resourceRoot); |
| 461 | + const ownerDocument = getDocumentFromRoot(resourceRoot); |
| 462 | + instance = createHTMLElement('script', scriptProps, ownerDocument); |
459 | 463 | markNodeAsResource(instance); |
460 | 464 | setInitialProperties(instance, 'link', scriptProps); |
461 | 465 | (getDocumentFromRoot(resourceRoot).head: any).appendChild(instance); |
@@ -753,7 +757,8 @@ export function acquireResource( |
753 | 757 | } |
754 | 758 |
|
755 | 759 | const styleProps = styleTagPropsFromRawProps(props); |
756 | | - instance = createHTMLElement('style', styleProps, hoistableRoot); |
| 760 | + const ownerDocument = getDocumentFromRoot(hoistableRoot); |
| 761 | + instance = createHTMLElement('style', styleProps, ownerDocument); |
757 | 762 |
|
758 | 763 | markNodeAsResource(instance); |
759 | 764 | setInitialProperties(instance, 'style', styleProps); |
@@ -786,7 +791,8 @@ export function acquireResource( |
786 | 791 | } |
787 | 792 |
|
788 | 793 | // Construct and insert a new instance |
789 | | - instance = createHTMLElement('link', stylesheetProps, hoistableRoot); |
| 794 | + const ownerDocument = getDocumentFromRoot(hoistableRoot); |
| 795 | + instance = createHTMLElement('link', stylesheetProps, ownerDocument); |
790 | 796 | markNodeAsResource(instance); |
791 | 797 | const linkInstance: HTMLLinkElement = (instance: any); |
792 | 798 | (linkInstance: any)._p = new Promise((resolve, reject) => { |
@@ -827,7 +833,8 @@ export function acquireResource( |
827 | 833 | } |
828 | 834 |
|
829 | 835 | // Construct and insert a new instance |
830 | | - instance = createHTMLElement('script', scriptProps, hoistableRoot); |
| 836 | + const ownerDocument = getDocumentFromRoot(hoistableRoot); |
| 837 | + instance = createHTMLElement('script', scriptProps, ownerDocument); |
831 | 838 | markNodeAsResource(instance); |
832 | 839 | setInitialProperties(instance, 'link', scriptProps); |
833 | 840 | (getDocumentFromRoot(hoistableRoot).head: any).appendChild(instance); |
|
0 commit comments