Skip to content

Commit

Permalink
fix: restore hasBeenAttached on resync (#19023) (#19068)
Browse files Browse the repository at this point in the history
Fixes #19023
  • Loading branch information
tepi committed Apr 2, 2024
1 parent 85f4a25 commit b83dfff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -456,7 +456,10 @@ protected void prepareForResync() {
stateNode.hasBeenAttached = false;
stateNode.hasBeenDetached = false;
});
visitNodeTreeBottomUp(sn -> sn.fireAttachListeners(true));
visitNodeTreeBottomUp(sn -> {
sn.hasBeenAttached = true;
sn.fireAttachListeners(true);
});
}

/**
Expand Down
Expand Up @@ -725,9 +725,13 @@ public void prepareForResync_nodeHasAttachAndDetachListeners_treeIsDirtyAndListe
tree.collectChanges(c -> {
});
Assert.assertEquals(0, tree.collectDirtyNodes().size());
Assert.assertTrue(node2.isClientSideInitialized());
Assert.assertTrue(node2.isAttached());

tree.getRootNode().prepareForResync();

Assert.assertFalse(node2.isClientSideInitialized());
Assert.assertTrue(node2.isAttached());
Assert.assertEquals(1, attachCount.get());
Assert.assertEquals(1, detachCount.get());

Expand All @@ -743,6 +747,16 @@ public void prepareForResync_nodeHasAttachAndDetachListeners_treeIsDirtyAndListe
Assert.assertTrue(
remaining.hasFeature(PushConfigurationParametersMap.class));

tree.collectChanges(change -> {
});
Assert.assertTrue(node2.isClientSideInitialized());

// Make sure detach listener is called when a resynced node is
// eventually detached
// In practice checks that node2.hasBeenAttached = true
node2.setParent(null);
Assert.assertEquals("Detach listener was not called on final detach", 2,
detachCount.get());
}

@Test
Expand Down

0 comments on commit b83dfff

Please sign in to comment.