mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Pass type to the relevant host config methods
Instead of reading it from the DOM node.
This commit is contained in:
@@ -408,7 +408,7 @@ const ARTRenderer = ReactFiberReconciler({
|
||||
// Noop
|
||||
},
|
||||
|
||||
commitUpdate(instance, oldProps, newProps) {
|
||||
commitUpdate(instance, type, oldProps, newProps) {
|
||||
instance._applyProps(instance, newProps, oldProps);
|
||||
},
|
||||
|
||||
@@ -467,7 +467,7 @@ const ARTRenderer = ReactFiberReconciler({
|
||||
// Noop
|
||||
},
|
||||
|
||||
prepareUpdate(domElement, oldProps, newProps) {
|
||||
prepareUpdate(domElement, type, oldProps, newProps) {
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
@@ -97,20 +97,16 @@ var DOMRenderer = ReactFiberReconciler({
|
||||
|
||||
finalizeInitialChildren(
|
||||
domElement : Instance,
|
||||
type : string,
|
||||
props : Props,
|
||||
rootContainerInstance : Container,
|
||||
) : void {
|
||||
// TODO: we normalize here because DOM renderer expects tag to be lowercase.
|
||||
// We can change DOM renderer to compare special case against upper case,
|
||||
// and use tagName (which is upper case for HTML DOM elements). Or we could
|
||||
// let the renderer "normalize" the fiber type so we don't have to read
|
||||
// the type from DOM. However we need to remember SVG is case-sensitive.
|
||||
var tag = domElement.tagName.toLowerCase();
|
||||
setInitialProperties(domElement, tag, props, rootContainerInstance);
|
||||
setInitialProperties(domElement, type, props, rootContainerInstance);
|
||||
},
|
||||
|
||||
prepareUpdate(
|
||||
domElement : Instance,
|
||||
type : string,
|
||||
oldProps : Props,
|
||||
newProps : Props
|
||||
) : boolean {
|
||||
@@ -119,21 +115,16 @@ var DOMRenderer = ReactFiberReconciler({
|
||||
|
||||
commitUpdate(
|
||||
domElement : Instance,
|
||||
type : string,
|
||||
oldProps : Props,
|
||||
newProps : Props,
|
||||
rootContainerInstance : Container,
|
||||
internalInstanceHandle : Object,
|
||||
) : void {
|
||||
// TODO: we normalize here because DOM renderer expects tag to be lowercase.
|
||||
// We can change DOM renderer to compare special case against upper case,
|
||||
// and use tagName (which is upper case for HTML DOM elements). Or we could
|
||||
// let the renderer "normalize" the fiber type so we don't have to read
|
||||
// the type from DOM. However we need to remember SVG is case-sensitive.
|
||||
var tag = domElement.tagName.toLowerCase();
|
||||
// Update the internal instance handle so that we know which props are
|
||||
// the current ones.
|
||||
precacheFiberNode(internalInstanceHandle, domElement);
|
||||
updateProperties(domElement, tag, oldProps, newProps, rootContainerInstance);
|
||||
updateProperties(domElement, type, oldProps, newProps, rootContainerInstance);
|
||||
},
|
||||
|
||||
shouldSetTextContent(props : Props) : boolean {
|
||||
|
||||
@@ -60,15 +60,15 @@ var NoopRenderer = ReactFiberReconciler({
|
||||
parentInstance.children.push(child);
|
||||
},
|
||||
|
||||
finalizeInitialChildren(domElement : Instance, props : Props) : void {
|
||||
finalizeInitialChildren(domElement : Instance, type : string, props : Props) : void {
|
||||
// Noop
|
||||
},
|
||||
|
||||
prepareUpdate(instance : Instance, oldProps : Props, newProps : Props) : boolean {
|
||||
prepareUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : boolean {
|
||||
return true;
|
||||
},
|
||||
|
||||
commitUpdate(instance : Instance, oldProps : Props, newProps : Props) : void {
|
||||
commitUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : void {
|
||||
instance.prop = newProps.prop;
|
||||
},
|
||||
|
||||
|
||||
@@ -373,7 +373,8 @@ module.exports = function<T, P, I, TI, C, CX>(
|
||||
const newProps = finishedWork.memoizedProps;
|
||||
const oldProps = current.memoizedProps;
|
||||
const rootContainerInstance = getRootHostContainer();
|
||||
commitUpdate(instance, oldProps, newProps, rootContainerInstance, finishedWork);
|
||||
const type = finishedWork.type;
|
||||
commitUpdate(instance, type, oldProps, newProps, rootContainerInstance, finishedWork);
|
||||
}
|
||||
detachRefIfNeeded(current, finishedWork);
|
||||
return;
|
||||
|
||||
@@ -215,6 +215,7 @@ module.exports = function<T, P, I, TI, C, CX>(
|
||||
}
|
||||
case HostComponent:
|
||||
popHostContext(workInProgress);
|
||||
const type = workInProgress.type;
|
||||
let newProps = workInProgress.pendingProps;
|
||||
if (current && workInProgress.stateNode != null) {
|
||||
// If we have an alternate, that means this is an update and we need to
|
||||
@@ -228,7 +229,7 @@ module.exports = function<T, P, I, TI, C, CX>(
|
||||
newProps = workInProgress.memoizedProps || oldProps;
|
||||
}
|
||||
const instance : I = workInProgress.stateNode;
|
||||
if (prepareUpdate(instance, oldProps, newProps)) {
|
||||
if (prepareUpdate(instance, type, oldProps, newProps)) {
|
||||
// This returns true if there was something to update.
|
||||
markUpdate(workInProgress);
|
||||
}
|
||||
@@ -249,14 +250,14 @@ module.exports = function<T, P, I, TI, C, CX>(
|
||||
// or completeWork depending on we want to add then top->down or
|
||||
// bottom->up. Top->down is faster in IE11.
|
||||
const instance = createInstance(
|
||||
workInProgress.type,
|
||||
type,
|
||||
newProps,
|
||||
rootContainerInstance,
|
||||
currentHostContext,
|
||||
workInProgress
|
||||
);
|
||||
appendAllChildren(instance, workInProgress);
|
||||
finalizeInitialChildren(instance, newProps, rootContainerInstance);
|
||||
finalizeInitialChildren(instance, type, newProps, rootContainerInstance);
|
||||
|
||||
workInProgress.stateNode = instance;
|
||||
if (workInProgress.ref) {
|
||||
|
||||
@@ -46,10 +46,10 @@ export type HostConfig<T, P, I, TI, C, CX> = {
|
||||
|
||||
createInstance(type : T, props : P, rootContainerInstance : C, hostContext : CX | null, internalInstanceHandle : OpaqueNode) : I,
|
||||
appendInitialChild(parentInstance : I, child : I | TI) : void,
|
||||
finalizeInitialChildren(parentInstance : I, props : P, rootContainerInstance : C) : void,
|
||||
finalizeInitialChildren(parentInstance : I, type : T, props : P, rootContainerInstance : C) : void,
|
||||
|
||||
prepareUpdate(instance : I, oldProps : P, newProps : P) : boolean,
|
||||
commitUpdate(instance : I, oldProps : P, newProps : P, rootContainerInstance : C, internalInstanceHandle : OpaqueNode) : void,
|
||||
prepareUpdate(instance : I, type : T, oldProps : P, newProps : P) : boolean,
|
||||
commitUpdate(instance : I, type : T, oldProps : P, newProps : P, rootContainerInstance : C, internalInstanceHandle : OpaqueNode) : void,
|
||||
|
||||
shouldSetTextContent(props : P) : boolean,
|
||||
resetTextContent(instance : I) : void,
|
||||
|
||||
Reference in New Issue
Block a user