Skip to content

Commit 1a4115e

Browse files
committed
remove the concept of itemScope and categorically treat itemProp as an opt out
1 parent 412905a commit 1a4115e

File tree

14 files changed

+300
-494
lines changed

14 files changed

+300
-494
lines changed

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* @flow
88
*/
99

10-
import type {ExoticNamespace} from '../shared/DOMNamespaces';
11-
1210
import {
1311
registrationNameDependencies,
1412
possibleRegistrationNames,
@@ -57,7 +55,12 @@ import {
5755
setValueForStyles,
5856
validateShorthandPropertyCollisionInDev,
5957
} from './CSSPropertyOperations';
60-
import {HTML_NAMESPACE} from '../shared/DOMNamespaces';
58+
import {
59+
HTML_NAMESPACE,
60+
MATH_NAMESPACE,
61+
SVG_NAMESPACE,
62+
getIntrinsicNamespace,
63+
} from '../shared/DOMNamespaces';
6164
import {
6265
getPropertyInfo,
6366
shouldIgnoreAttribute,
@@ -381,14 +384,10 @@ function updateDOMProperties(
381384
export function createHTMLElement(
382385
type: string,
383386
props: Object,
384-
rootContainerElement: Element | Document | DocumentFragment,
387+
ownerDocument: Document,
385388
): Element {
386389
let isCustomComponentTag;
387390

388-
// We create tags in the namespace of their parent container, except HTML
389-
// tags get no namespace.
390-
const ownerDocument: Document =
391-
getOwnerDocumentFromRootContainer(rootContainerElement);
392391
let domElement: Element;
393392
if (__DEV__) {
394393
isCustomComponentTag = isCustomComponent(type, props);
@@ -473,17 +472,18 @@ export function createHTMLElement(
473472
return domElement;
474473
}
475474

476-
// Creates elements in the HTML either SVG or Math namespace
477-
export function createElementNS(
478-
namespaceURI: ExoticNamespace,
475+
export function createSVGElement(
479476
type: string,
480-
rootContainerElement: Element | Document | DocumentFragment,
477+
ownerDocument: Document,
481478
): Element {
482-
// This
483-
const ownerDocument: Document =
484-
getOwnerDocumentFromRootContainer(rootContainerElement);
479+
return ownerDocument.createElementNS(SVG_NAMESPACE, type);
480+
}
485481

486-
return ownerDocument.createElementNS(namespaceURI, type);
482+
export function createMathElement(
483+
type: string,
484+
ownerDocument: Document,
485+
): Element {
486+
return ownerDocument.createElementNS(MATH_NAMESPACE, type);
487487
}
488488

489489
export function createTextNode(
@@ -871,7 +871,7 @@ export function diffHydratedProperties(
871871
rawProps: Object,
872872
isConcurrentMode: boolean,
873873
shouldWarnDev: boolean,
874-
namespaceDEV?: string,
874+
parentNamespaceDev: string,
875875
): null | Array<mixed> {
876876
let isCustomComponentTag;
877877
let extraAttributeNames: Set<string>;
@@ -1114,7 +1114,11 @@ export function diffHydratedProperties(
11141114
propertyInfo,
11151115
);
11161116
} else {
1117-
if (namespaceDEV === HTML_NAMESPACE) {
1117+
let ownNamespaceDev = parentNamespaceDev;
1118+
if (ownNamespaceDev === HTML_NAMESPACE) {
1119+
ownNamespaceDev = getIntrinsicNamespace(tag);
1120+
}
1121+
if (ownNamespaceDev === HTML_NAMESPACE) {
11181122
// $FlowFixMe - Should be inferred as not undefined.
11191123
extraAttributeNames.delete(propKey.toLowerCase());
11201124
} else {

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,32 @@
99

1010
import type {Instance, Container} from './ReactDOMHostConfig';
1111

12-
import {isAttributeNameSafe} from '../shared/DOMProperty';
13-
import {precacheFiberNode} from './ReactDOMComponentTree';
12+
import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext';
1413

1514
import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals.js';
1615
const {Dispatcher} = ReactDOMSharedInternals;
16+
import {
17+
checkAttributeStringCoercion,
18+
checkPropStringCoercion,
19+
} from 'shared/CheckStringCoercion';
20+
1721
import {DOCUMENT_NODE} from '../shared/HTMLNodeType';
22+
import {isAttributeNameSafe} from '../shared/DOMProperty';
23+
import {SVG_NAMESPACE} from '../shared/DOMNamespaces';
1824
import {
1925
validatePreloadArguments,
2026
validatePreinitArguments,
2127
getValueDescriptorExpectingObjectForWarning,
2228
getValueDescriptorExpectingEnumForWarning,
2329
} from '../shared/ReactDOMResourceValidation';
30+
31+
import {precacheFiberNode} from './ReactDOMComponentTree';
2432
import {createHTMLElement, setInitialProperties} from './ReactDOMComponent';
25-
import {
26-
checkAttributeStringCoercion,
27-
checkPropStringCoercion,
28-
} from 'shared/CheckStringCoercion';
2933
import {
3034
getResourcesFromRoot,
3135
isMarkedResource,
3236
markNodeAsResource,
3337
} from './ReactDOMComponentTree';
34-
import {SVG_NAMESPACE} from '../shared/DOMNamespaces';
35-
import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext';
3638

3739
// The resource types we support. currently they match the form for the as argument.
3840
// In the future this may need to change, especially when modules / scripts are supported
@@ -414,7 +416,8 @@ function preinit(href: string, options: PreinitOptions) {
414416
if (preloadProps) {
415417
adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps);
416418
}
417-
instance = createHTMLElement('link', stylesheetProps, resourceRoot);
419+
const ownerDocument = getDocumentFromRoot(resourceRoot);
420+
instance = createHTMLElement('link', stylesheetProps, ownerDocument);
418421
markNodeAsResource(instance);
419422
setInitialProperties(instance, 'link', stylesheetProps);
420423
insertStylesheet(instance, precedence, resourceRoot);
@@ -455,7 +458,8 @@ function preinit(href: string, options: PreinitOptions) {
455458
if (preloadProps) {
456459
adoptPreloadPropsForScript(scriptProps, preloadProps);
457460
}
458-
instance = createHTMLElement('script', scriptProps, resourceRoot);
461+
const ownerDocument = getDocumentFromRoot(resourceRoot);
462+
instance = createHTMLElement('script', scriptProps, ownerDocument);
459463
markNodeAsResource(instance);
460464
setInitialProperties(instance, 'link', scriptProps);
461465
(getDocumentFromRoot(resourceRoot).head: any).appendChild(instance);
@@ -753,7 +757,8 @@ export function acquireResource(
753757
}
754758

755759
const styleProps = styleTagPropsFromRawProps(props);
756-
instance = createHTMLElement('style', styleProps, hoistableRoot);
760+
const ownerDocument = getDocumentFromRoot(hoistableRoot);
761+
instance = createHTMLElement('style', styleProps, ownerDocument);
757762

758763
markNodeAsResource(instance);
759764
setInitialProperties(instance, 'style', styleProps);
@@ -786,7 +791,8 @@ export function acquireResource(
786791
}
787792

788793
// Construct and insert a new instance
789-
instance = createHTMLElement('link', stylesheetProps, hoistableRoot);
794+
const ownerDocument = getDocumentFromRoot(hoistableRoot);
795+
instance = createHTMLElement('link', stylesheetProps, ownerDocument);
790796
markNodeAsResource(instance);
791797
const linkInstance: HTMLLinkElement = (instance: any);
792798
(linkInstance: any)._p = new Promise((resolve, reject) => {
@@ -827,7 +833,8 @@ export function acquireResource(
827833
}
828834

829835
// Construct and insert a new instance
830-
instance = createHTMLElement('script', scriptProps, hoistableRoot);
836+
const ownerDocument = getDocumentFromRoot(hoistableRoot);
837+
instance = createHTMLElement('script', scriptProps, ownerDocument);
831838
markNodeAsResource(instance);
832839
setInitialProperties(instance, 'link', scriptProps);
833840
(getDocumentFromRoot(hoistableRoot).head: any).appendChild(instance);

0 commit comments

Comments
 (0)