next.js
530382ae - Fix hydration error higlight when tag matched multi times (#64133)

Commit
1 year ago
Fix hydration error higlight when tag matched multi times (#64133) ### What We introduced a new algorithm to find the matched hydration error tags, when there're two tags indicating children and parent as bad descendence relationship. Now we search for the child first from the last index, and then from found child to search its above parent. This way we can find the two related tags in O(1), since they could be not directly nested. ### Why When a hydration error occurred, such as bad nesting `div` under `p`, one of the tag `div` is matched multiple times in the component stack, it shouldn't be highlighted multiple times. This PR fixes the bad matching about multiple nested tags, e.g. when there're many `div` tag and `div` is one of the bad tag, only the one directly under p should be highlited. Case ``` Page > div > div > p > div ``` Current Result: all `div` and `p` get highlighted, `[]` represents highlighted. ``` Page > [div] > [div] > [p] > [div] ``` Expected: only the related 2 tags are highlighted, `[]` represents highlighted. ``` Page > div > div > [p] > [div] ``` Thanks @JohnPhamous for reporting the issue Closes NEXT-3022
Author
Parents
Loading