const Reconciler = require("react-reconciler");
const { createElement, getHostContextNode } = require("../utils/createElement");
const noop = () => {};
const SlackRenderer = Reconciler({
appendInitialChild: function appendInitialChild(parentInstance, child) {
parentInstance.appendChild(child);
child.parent = parentInstance;
},
createInstance: function createInstance(type, props) {
return createElement(type, props);
},
createTextInstance: function createTextInstance(
text,
rootContainerInstance,
internalInstanceHandle
) {
return text;
},
finalizeInitialChildren: function finalizeInitialChildren(element, type, props) {
return false;
},
getPublicInstance: function getPublicInstance(instance) {
return instance;
},
prepareForCommit: noop,
prepareUpdate: function prepareUpdate(element, type, oldProps, newProps) {
return true;
},
resetAfterCommit: noop,
resetTextContent: noop,
getRootHostContext: function getRootHostContext(rootInstance) {
return getHostContextNode(rootInstance);
},
getChildHostContext: function getChildHostContext() {
return {};
},
shouldSetTextContent: function shouldSetTextContent(type, props) {
return false;
},
now: Date.now,
useSyncScheduling: true,
mutation: {
appendChild: function appendChild(parentInstance, child) {
parentInstance.appendChild(child);
child.parent = parentInstance;
},
appendChildToContainer: function appendChildToContainer(parentInstance, child) {
parentInstance.appendChild(child);
child.parent = parentInstance;
},
removeChild: noop,
removeChildFromContainer: noop,
insertBefore: noop,
commitUpdate: noop,
commitMount: noop,
commitTextUpdate: noop
}
});
module.exports = {
/**
* @param {ReactElement} element
* @return {Object}
*/
render: function render(element) {
const container = createElement("ROOT");
const node = SlackRenderer.createContainer(container);
SlackRenderer.updateContainer(element, node, null);
return container.render();
}
};
import { HOST_COMPONENT, HOST_TEXT, FundamentalComponent, HOST_PORTAL } from '../../shared/workTags';
import appendInitialChild from './appendInitialChild';
export default function appendAllChildren (
instance,
workInProgress
) {
let node = workInProgress.child;
while (node !== null) {
if (node.tag === HOST_COMPONENT || node.tag === HOST_TEXT) {
appendInitialChild(instance, node.stateNode);
} else if (node.tag === FundamentalComponent) {
appendInitialChild(instance, node.stateNode.instance);
} else if (node.tag === HOST_PORTAL) {
// If we have a portal child, then we don't want to traverse
// down its children. Instead, we'll get insertions from each child in
// the portal directly.
} else if (node.child !== null) {
node.child.return = node;
node = node.child;
continue;
}
if (node === workInProgress) {
return;
}
while (node.sibling === null) {
if (node.return === null || node.return === workInProgress) {
return;
}
node = node.return;
}
node.sibling.return = node.return;
node = node.sibling;
}
}
import Reconciler from "react-reconciler";
const log = (...args) => {
// console.log(...args);
};
const FunnyRenderer = Reconciler({
createInstance(type, props) {
log("createInstance", { type, props });
return {
type,
props,
children: [],
};
},
prepareForCommit() {},
getRootHostContext(rootInstance) {},
resetAfterCommit() {},
getChildHostContext() {},
shouldSetTextContent(type, props) {
return false;
},
createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
return text;
},
appendInitialChild: (parent, child) => {
parent.children.push(child);
log("appendInitialChild", { parent, child });
},
appendChild(parent, child) {
parent.children.push(child);
log("appendChild", { parent, child });
},
finalizeInitialChildren(wordElement, type, props) {
return false;
},
appendChildToContainer: (container, child) => {
if (!container.children) {
container.children = [];
}
container.children.push(child);
log("appendChildToContainer", { container, child });
},
clearContainer: () => {},
supportsMutation: true,
});
const RendererPublicAPI = {
render(element, container, callback) {
log({ element, container, callback });
// Call MyRenderer.updateContainer() to schedule changes on the roots.
// See ReactDOM, React Native, or React ART for practical examples.
if (!container.__rootContainer) {
log("creating container");
container.__rootContainer = FunnyRenderer.createContainer(container, false);
}
FunnyRenderer.updateContainer(element, container.__rootContainer);
},
};
export default RendererPublicAPI;
Accelerate Your Automation Test Cycles With LambdaTest
Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.