refactor(internals): use non enumerable props

This commit is contained in:
moklick
2022-05-26 19:55:03 +02:00
parent 03f0be62f7
commit 27b5de2d96
8 changed files with 41 additions and 22 deletions
+5 -4
View File
@@ -13,7 +13,7 @@ import {
Transform,
XYPosition,
} from '../../types';
import { rectToBox } from '../../utils';
import { handleBoundsSymbol, rectToBox } from '../../utils';
export type CreateEdgeTypes = (edgeTypes: EdgeTypes) => EdgeTypesWrapped;
@@ -168,10 +168,11 @@ export function isEdgeVisible({
export function getNodeData(nodeInternals: NodeInternals, nodeId: string): [Rect, NodeHandleBounds | null, boolean] {
const node = nodeInternals.get(nodeId);
const handleBounds = node?.handleBounds;
const handleBounds = node?.[handleBoundsSymbol] || null;
const isInvalid =
!node ||
!node.handleBounds ||
!handleBounds ||
!node.width ||
!node.height ||
typeof node.positionAbsolute?.x === 'undefined' ||
@@ -184,7 +185,7 @@ export function getNodeData(nodeInternals: NodeInternals, nodeId: string): [Rect
width: node?.width || 0,
height: node?.height || 0,
},
handleBounds || null,
handleBounds,
!isInvalid,
];
}
+3 -2
View File
@@ -11,6 +11,7 @@ import {
ReactFlowState,
WrapNodeProps,
} from '../../types';
import { isParentSymbol, zSymbol } from '../../utils';
interface NodeRendererProps {
nodeTypes: NodeTypesWrapped;
@@ -117,8 +118,8 @@ const NodeRenderer = (props: NodeRendererProps) => {
isConnectable={isConnectable}
resizeObserver={resizeObserver}
dragHandle={node.dragHandle}
zIndex={node.z ?? 0}
isParent={!!node.isParent}
zIndex={node[zSymbol] ?? 0}
isParent={!!node[isParentSymbol]}
noDragClassName={props.noDragClassName}
noPanClassName={props.noPanClassName}
/>