fix(devtools): fix tests and leave todo related to possible typing refactor

This commit is contained in:
AleksanderBodurri 2020-03-22 19:24:01 -04:00 committed by Minko Gechev
parent 60a4e56a95
commit a8ba83cd30
3 changed files with 4 additions and 3 deletions

View file

@ -83,6 +83,7 @@ const stopProfilingCallback = (messageBus: MessageBus<Events>) => () => {
};
const selectedComponentCallback = (position: ElementPosition) => {
// TODO: figure out proper typing of the node variable.
const node = queryDirectiveForest(position, getDirectiveForest());
setConsoleReference(node);
};

View file

@ -27,7 +27,7 @@ export interface ComponentInstanceType {
export interface ComponentTreeNode extends DevToolsNode<DirectiveInstanceType, ComponentInstanceType> {
children: ComponentTreeNode[];
position: ElementPosition;
position?: ElementPosition;
}
export const getLatestComponentState = (query: ComponentExplorerViewQuery): DirectivesProperties | undefined => {

View file

@ -23,8 +23,8 @@ const _setConsoleReference = (node: ComponentTreeNode) => {
};
const prepareCurrentReferencesForInsertion = (node: ComponentTreeNode) => {
const foundIndex = nodesForConsoleReference.findIndex(nodeToLookFor =>
arrayEquals(nodeToLookFor.position, node.position)
const foundIndex = nodesForConsoleReference.findIndex(
nodeToLookFor => nodeToLookFor.position && node.position && arrayEquals(nodeToLookFor.position, node.position)
);
if (foundIndex !== -1) {
nodesForConsoleReference.splice(foundIndex, 1);