Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function toTree(vnode) {
if (vnode == null) {
return null
}
// TODO(lmr): I'm not really sure I understand whether or not this is what
// i should be doing, or if this is a hack for something i'm doing wrong
// somewhere else. Should talk to sebastian about this perhaps
const node = findCurrentFiberUsingSlowPath(vnode)
switch (node.tag) {
case HostRoot: // 3
return toTree(node.child)
case HostPortal: // 4
return toTree(node.child)
case ClassComponent:
return {
nodeType: 'class',
type: node.type,
props: { ...node.memoizedProps },
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: node.stateNode,
rendered: childrenToTree(node.child),
}
case FunctionalComponent: // 1
function toTree(vnode) {
if (vnode == null) {
return null;
}
// TODO(lmr): I'm not really sure I understand whether or not this is what
// i should be doing, or if this is a hack for something i'm doing wrong
// somewhere else. Should talk to sebastian about this perhaps
const node = findCurrentFiberUsingSlowPath(vnode);
switch (node.tag) {
case HostRoot: // 3
return toTree(node.child);
case HostPortal: // 4
return toTree(node.child);
case ClassComponent:
return {
nodeType: 'class',
type: node.type,
props: { ...node.memoizedProps },
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: node.stateNode,
rendered: childrenToTree(node.child),
};
case FunctionalComponent: // 1
getInspectorDataForViewTag = function(viewTag: number): Object {
const closestInstance = getFiberFromTag(viewTag);
// Handle case where user clicks outside of ReactNative
if (!closestInstance) {
return {
hierarchy: [],
props: emptyObject,
selection: null,
source: null,
};
}
const fiber = findCurrentFiberUsingSlowPath(closestInstance);
const fiberHierarchy = getOwnerHierarchy(fiber);
const instance = lastNonHostInstance(fiberHierarchy);
const hierarchy = createHierarchy(fiberHierarchy);
const props = getHostProps(instance);
const source = instance._debugSource;
const selection = fiberHierarchy.indexOf(instance);
return {
hierarchy,
props,
selection,
source,
};
};
} else {
function toTree(vnode) {
if (vnode == null) {
return null;
}
// TODO(lmr): I'm not really sure I understand whether or not this is what
// i should be doing, or if this is a hack for something i'm doing wrong
// somewhere else. Should talk to sebastian about this perhaps
const node = findCurrentFiberUsingSlowPath(vnode);
switch (node.tag) {
case HostRoot: // 3
return childrenToTree(node.child);
case HostPortal: { // 4
const {
stateNode: { containerInfo },
memoizedProps: children,
} = node;
const props = { containerInfo, children };
return {
nodeType: 'portal',
type: Portal,
props,
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: null,
getInspectorDataForViewTag = function(viewTag: number): Object {
const closestInstance = getClosestInstanceFromNode(viewTag);
// Handle case where user clicks outside of ReactNative
if (!closestInstance) {
return {
hierarchy: [],
props: emptyObject,
selection: null,
source: null,
};
}
const fiber = findCurrentFiberUsingSlowPath(closestInstance);
const fiberHierarchy = getOwnerHierarchy(fiber);
const instance = lastNonHostInstance(fiberHierarchy);
const hierarchy = createHierarchy(fiberHierarchy);
const props = getHostProps(instance);
const source = instance._debugSource;
const selection = fiberHierarchy.indexOf(instance);
return {
hierarchy,
props,
selection,
source,
};
};
} else {
function toTree(vnode) {
if (vnode == null) {
return null
}
// TODO(lmr): I'm not really sure I understand whether or not this is what
// i should be doing, or if this is a hack for something i'm doing wrong
// somewhere else. Should talk to sebastian about this perhaps
const node = findCurrentFiberUsingSlowPath(vnode)
switch (node.tag) {
case HostRoot: // 3
return toTree(node.child)
case HostPortal: // 4
return toTree(node.child)
case ClassComponent:
return {
nodeType: 'class',
type: node.type,
props: {...node.memoizedProps},
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: node.stateNode,
rendered: childrenToTree(node.child),
}
case FunctionalComponent: // 1
function toTree(vnode) {
if (vnode == null) {
return null;
}
// TODO(lmr): I'm not really sure I understand whether or not this is what
// i should be doing, or if this is a hack for something i'm doing wrong
// somewhere else. Should talk to sebastian about this perhaps
const node = findCurrentFiberUsingSlowPath(vnode);
switch (node.tag) {
case HostRoot: // 3
return childrenToTree(node.child);
case HostPortal: {
// 4
return childrenToTree(node.child);
}
case ClassComponent:
return {
nodeType: 'class',
type: node.type,
props: {...node.memoizedProps},
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: node.stateNode,
rendered: childrenToTree(node.child)
function findAllInRenderedFiberTreeInternal(fiber, test) {
if (!fiber) {
return [];
}
const currentParent = findCurrentFiberUsingSlowPath(fiber);
if (!currentParent) {
return [];
}
let node = currentParent;
let ret = [];
while (true) {
if (
node.tag === HostComponent ||
node.tag === HostText ||
node.tag === ClassComponent ||
node.tag === ClassComponentLazy ||
node.tag === FunctionalComponent ||
node.tag === FunctionalComponentLazy
) {
const publicInst = node.stateNode;
if (test(publicInst)) {
function flatten(
element: Fiber,
root: Root,
): (Element | string)[] {
const node: Fiber = findCurrentFiberUsingSlowPath(element);
if (node.tag === Tag.HostText) {
return [node.memoizedProps as string];
}
const props = {...(node.memoizedProps || {})};
const {children, descendants} = childrenToTree(node.child, root);
return [
new Element(
{
tag: node.tag,
type: node.type,
props,
instance: node.stateNode,
},