From b3926dad8b7ffe947acb9ed041807a1facb18e35 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Fri, 6 Sep 2024 13:23:14 -0600 Subject: [PATCH] better client message and assertion, https://github.com/phetsims/density-buoyancy-common/issues/386 Signed-off-by: Michael Kauzmann --- js/nodes/IndexedNodeIO.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/js/nodes/IndexedNodeIO.ts b/js/nodes/IndexedNodeIO.ts index 364502e93..c25d0230d 100644 --- a/js/nodes/IndexedNodeIO.ts +++ b/js/nodes/IndexedNodeIO.ts @@ -98,6 +98,7 @@ const IndexedNodeIO = new IOType( 'IndexedNodeIO', { // away another IndexedNode state set. See https://github.com/phetsims/ph-scale/issues/227 const children = nodeParent.children; const currentIndex = nodeParent.indexOfChild( node ); + assert && assert( stateObject.index < children.length, 'index goes beyond number of children' ); children[ currentIndex ] = children[ stateObject.index ]; children[ stateObject.index ] = node; nodeParent.setChildren( children );