Skip to content

Commit b7fd96f

Browse files
committed
Merge branch 'reactime7' of https://github.com/rtviner/reactime into reactime7
2 parents 39a60c2 + fb273d5 commit b7fd96f

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

src/app/containers/MainContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const mixpanel = require("mixpanel").init("12fa2800ccbf44a5c36c37bc9776e4c0", {
1919
});
2020

2121

22-
2322
function MainContainer(): any {
2423
const [store, dispatch] = useStoreContext();
2524
const { tabs, currentTab, port: currentPort } = store;

src/backend/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,37 @@ window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
6060
case 'setPause':
6161
mode.paused = payload;
6262
break;
63-
case 'onHover':
63+
case 'onHover':
64+
// console.log("curr payload ", payload);
6465
if (Array.isArray(payload)) {
66+
// console.log('inside array is array if block')
6567
for (let i = 0; i < payload.length; i + 1) {
68+
// console.log("current payload value: ", payload[i]);
6669
let element = document.getElementById(payload[i])
6770
if (element !== null) {
6871
element.style.backgroundColor = '#C0D9D9';
6972
}
7073
}
7174
} else {
72-
let element = document.getElementById(payload)
75+
let element = document.querySelector(`.${payload}`);
76+
// console.log("element: ", element);
7377
if (element !== null) {
78+
// console.log("element style: ", element.style)
7479
element.style.backgroundColor = '#C0D9D9';
7580
}
7681
}
7782
break;
7883
case 'onHoverExit':
7984
if(Array.isArray(payload)){
8085
for (let i=0; i<payload.length;i++){
81-
let element = document.getElementById(payload[i])
86+
let element = document.querySelector(`.${payload}`);
8287
if (element !== null) {
83-
element.style.backgroundColor = '';
84-
}
88+
element.style.backgroundColor = '';
89+
}
8590
}
8691
} else {
87-
let element = document.getElementById(payload)
92+
let element = document.querySelector(`.${payload}`);
93+
// console.log("element style: ", element.style)
8894
if (element !== null) {
8995
element.style.backgroundColor = '';
9096
}

src/backend/linkFiber.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ function createTree(
356356
isRecoil === false
357357
) {
358358
if (memoizedState.queue) {
359-
// console.log("line 357...")
360359
// Hooks states are stored as a linked list using memoizedState.next,
361360
// so we must traverse through the list and get the states.
362361
// We then store them along with the corresponding memoizedState.queue,
@@ -411,17 +410,37 @@ function createTree(
411410

412411
while (pointer !== null) {
413412
if(pointer.stateNode !== null){
414-
rtid = "fromLinkFiber" + rtidCounter++
415-
recoilDomNode[currentFiber.elementType.name].push(rtid)
416-
pointer.stateNode.setAttribute("id", rtid)
413+
rtid = "fromLinkFiber" + rtidCounter++;
414+
recoilDomNode[currentFiber.elementType.name].push(rtid)
415+
// check if rtid is already present
416+
// remove existing rtid before adding a new one
417+
if (pointer.stateNode.classList.length > 0) {
418+
let lastClass = pointer.stateNode.classList[pointer.stateNode.classList.length -1];
419+
// console.log("last class: ", lastClass, "linkFiber class? ", lastClass.includes("fromLinkFiber"));
420+
if (lastClass.includes("fromLinkFiber")) {
421+
pointer.stateNode.classList.remove(lastClass);
422+
}
423+
}
424+
425+
pointer.stateNode.classList.add(rtid)
417426
}
418427
pointer = pointer.child
419428
}
420429
} else {
421430
if (currentFiber.child && currentFiber.child.stateNode && currentFiber.child.stateNode.setAttribute) {
422-
rtid = "fromLinkFiber" + rtidCounter
423-
currentFiber.child.stateNode.setAttribute("id", rtid);
431+
432+
rtid = "fromLinkFiber" + rtidCounter;
433+
// check if rtid is already present
434+
// remove existing rtid before adding a new one
435+
if (currentFiber.child.stateNode.classList.length > 0) {
436+
let lastClass = currentFiber.child.stateNode.classList[currentFiber.child.stateNode.classList.length -1];
437+
// console.log("lastClass: ", lastClass, "linkFiber class? ", lastClass.includes("fromLinkFiber"));
438+
if (lastClass.includes("fromLinkFiber")) {
439+
currentFiber.child.stateNode.classList.remove(lastClass);
440+
}
424441
}
442+
currentFiber.child.stateNode.classList.add(rtid);
443+
}
425444
rtidCounter++;
426445
}
427446
// checking if tree fromSibling is true

0 commit comments

Comments
 (0)