mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-27 04:45:08 +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;
|
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 (!$current && $new) {
|
||||||
if (isNewComponent) {
|
if (isNewComponent) {
|
||||||
$new = initComponent($new as VirtualElementComponent, $parent, index, parentEl);
|
$new = initComponent($new as VirtualElementComponent, $parent, index, parentEl);
|
||||||
|
@ -449,7 +449,8 @@ function forceUpdateComponent(componentInstance: ComponentInstance) {
|
|||||||
|
|
||||||
export function getTarget($element: VirtualElement): Node | undefined {
|
export function getTarget($element: VirtualElement): Node | undefined {
|
||||||
if (isComponentElement($element)) {
|
if (isComponentElement($element)) {
|
||||||
return getTarget($element.children[0]);
|
const componentElement = $element.children[0];
|
||||||
|
return componentElement ? getTarget(componentElement) : undefined;
|
||||||
} else {
|
} else {
|
||||||
return $element.target;
|
return $element.target;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user