Skip to content

Commit a066705

Browse files
committed
hide hostcontexttype by exposing a getter for ancestorInfo.resourceFormOnly
1 parent 0fb69cf commit a066705

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

packages/react-dom-bindings/src/client/ReactDOMFloatClient.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {Instance, Container, HostContextDev} from './ReactDOMHostConfig';
10+
import type {Instance, Container} from './ReactDOMHostConfig';
1111

1212
import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals.js';
1313
const {Dispatcher} = ReactDOMSharedInternals;
@@ -33,6 +33,7 @@ import {
3333
getCurrentRootHostContainer,
3434
getHostContext,
3535
} from 'react-reconciler/src/ReactFiberHostContext';
36+
import {getResourceFormOnly} from './validateDOMNesting';
3637

3738
// The resource types we support. currently they match the form for the as argument.
3839
// In the future this may need to change, especially when modules / scripts are supported
@@ -1336,8 +1337,8 @@ function insertResourceInstanceBefore(
13361337
export function isHostResourceType(type: string, props: Props): boolean {
13371338
let resourceFormOnly: boolean;
13381339
if (__DEV__) {
1339-
const hostContextDev: HostContextDev = (getHostContext(): any);
1340-
resourceFormOnly = (hostContextDev.ancestorInfo: any).resourceFormOnly;
1340+
const hostContext = getHostContext();
1341+
resourceFormOnly = getResourceFormOnly(hostContext);
13411342
}
13421343
switch (type) {
13431344
case 'meta':

packages/react-dom-bindings/src/client/ReactDOMHostConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export interface SuspenseInstance extends Comment {
133133
}
134134
export type HydratableInstance = Instance | TextInstance | SuspenseInstance;
135135
export type PublicInstance = Element | Text;
136-
export type HostContextDev = {
136+
type HostContextDev = {
137137
namespace: string,
138138
ancestorInfo: mixed,
139139
...

packages/react-dom-bindings/src/client/validateDOMNesting.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
let validateDOMNesting = () => {};
99
let updatedAncestorInfo = () => {};
10+
let getResourceFormOnly = () => false;
1011

1112
if (__DEV__) {
1213
// This validation code was written based on the HTML5 parsing spec:
@@ -478,6 +479,10 @@ if (__DEV__) {
478479
);
479480
}
480481
};
482+
483+
getResourceFormOnly = hostContextDev => {
484+
return hostContextDev.ancestorInfo.resourceFormOnly;
485+
};
481486
}
482487

483-
export {updatedAncestorInfo, validateDOMNesting};
488+
export {updatedAncestorInfo, validateDOMNesting, getResourceFormOnly};

0 commit comments

Comments
 (0)