mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-26 20:34:44 +01:00
[Debug] Teact: Assert when cached virtual element was moved within tree
This commit is contained in:
parent
233979405a
commit
eb0e304ff8
@ -98,6 +98,13 @@ function renderWithVirtual(
|
||||
return $new;
|
||||
}
|
||||
|
||||
if (DEBUG && $new) {
|
||||
const newTarget = getTarget($new);
|
||||
if (newTarget && (!$current || newTarget !== getTarget($current))) {
|
||||
throw new Error('[Teact] Cached virtual element was moved within tree');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$current && $new) {
|
||||
if (isNewComponent) {
|
||||
$new = initComponent($new as VirtualElementComponent, $parent, index, parentEl);
|
||||
|
@ -449,7 +449,8 @@ function forceUpdateComponent(componentInstance: ComponentInstance) {
|
||||
|
||||
export function getTarget($element: VirtualElement): Node | undefined {
|
||||
if (isComponentElement($element)) {
|
||||
return getTarget($element.children[0]);
|
||||
const componentElement = $element.children[0];
|
||||
return componentElement ? getTarget(componentElement) : undefined;
|
||||
} else {
|
||||
return $element.target;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user