|
7 | 7 | * @flow |
8 | 8 | */ |
9 | 9 |
|
10 | | -import type { |
11 | | - FloatRoot, |
12 | | - StyleResource, |
13 | | - ScriptResource, |
14 | | -} from './ReactDOMFloatClient'; |
| 10 | +import type {FloatRoot, RootResources} from './ReactDOMFloatClient'; |
15 | 11 | import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; |
16 | 12 | import type {ReactScopeInstance} from 'shared/ReactTypes'; |
17 | 13 | import type { |
@@ -53,6 +49,7 @@ const internalEventHandlersKey = '__reactEvents$' + randomKey; |
53 | 49 | const internalEventHandlerListenersKey = '__reactListeners$' + randomKey; |
54 | 50 | const internalEventHandlesSetKey = '__reactHandles$' + randomKey; |
55 | 51 | const internalRootNodeResourcesKey = '__reactResources$' + randomKey; |
| 52 | +const internalResourceMarker = '__reactMarker$' + randomKey; |
56 | 53 |
|
57 | 54 | export function detachDeletedInstance(node: Instance): void { |
58 | 55 | // TODO: This function is only called on host components. I don't think all of |
@@ -282,15 +279,22 @@ export function doesTargetHaveEventHandle( |
282 | 279 | return eventHandles.has(eventHandle); |
283 | 280 | } |
284 | 281 |
|
285 | | -export function getResourcesFromRoot( |
286 | | - root: FloatRoot, |
287 | | -): {styles: Map<string, StyleResource>, scripts: Map<string, ScriptResource>} { |
| 282 | +export function getResourcesFromRoot(root: FloatRoot): RootResources { |
288 | 283 | let resources = (root: any)[internalRootNodeResourcesKey]; |
289 | 284 | if (!resources) { |
290 | 285 | resources = (root: any)[internalRootNodeResourcesKey] = { |
291 | 286 | styles: new Map(), |
292 | 287 | scripts: new Map(), |
| 288 | + head: new Map(), |
293 | 289 | }; |
294 | 290 | } |
295 | 291 | return resources; |
296 | 292 | } |
| 293 | + |
| 294 | +export function isMarkedResource(node: Node): boolean { |
| 295 | + return !!(node: any)[internalResourceMarker]; |
| 296 | +} |
| 297 | + |
| 298 | +export function markNodeAsResource(node: Node) { |
| 299 | + (node: any)[internalResourceMarker] = true; |
| 300 | +} |
0 commit comments