Skip to content

Commit

Permalink
assert no additional children, see phetsims/sun#860
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Aug 19, 2024
1 parent a176698 commit f337fd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion js/NumberControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import optionize, { combineOptions } from '../../phet-core/js/optionize.js';
import IntentionalAny from '../../phet-core/js/types/IntentionalAny.js';
import PickOptional from '../../phet-core/js/types/PickOptional.js';
import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import { AlignBox, extendsWidthSizable, Font, HBox, isWidthSizable, Node, NodeOptions, PaintColorProperty, Text, TextOptions, VBox, WidthSizable } from '../../scenery/js/imports.js';
import { AlignBox, assertNoAdditionalChildren, extendsWidthSizable, Font, HBox, isWidthSizable, Node, NodeOptions, PaintColorProperty, Text, TextOptions, VBox, WidthSizable } from '../../scenery/js/imports.js';
import ArrowButton, { ArrowButtonOptions } from '../../sun/js/buttons/ArrowButton.js';
import HSlider from '../../sun/js/HSlider.js';
import Slider, { SliderOptions } from '../../sun/js/Slider.js';
Expand Down Expand Up @@ -576,6 +576,9 @@ export default class NumberControl extends WidthSizable( Node ) {
arrowEnabledListener && options.enabledRangeProperty && options.enabledRangeProperty.unlink( arrowEnabledListener );
};

// Decorating with additional content is an anti-pattern, see https://github.com/phetsims/sun/issues/860
assert && assertNoAdditionalChildren( this );

// support for binder documentation, stripped out in builds and only runs when ?binder is specified
assert && phet?.chipper?.queryParameters?.binder && InstanceRegistry.registerDataURL( 'scenery-phet', 'NumberControl', this );
}
Expand Down
5 changes: 4 additions & 1 deletion js/keyboard/help/KeyboardHelpSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import StringProperty from '../../../../axon/js/StringProperty.js';
import TReadOnlyProperty, { isTReadOnlyProperty } from '../../../../axon/js/TReadOnlyProperty.js';
import optionize, { combineOptions } from '../../../../phet-core/js/optionize.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import { HBox, Node, ReadingBlock, ReadingBlockOptions, RichText, RichTextOptions, VBox, VBoxOptions } from '../../../../scenery/js/imports.js';
import { assertNoAdditionalChildren, HBox, Node, ReadingBlock, ReadingBlockOptions, RichText, RichTextOptions, VBox, VBoxOptions } from '../../../../scenery/js/imports.js';
import ResponsePacket from '../../../../utterance-queue/js/ResponsePacket.js';
import PhetFont from '../../PhetFont.js';
import sceneryPhet from '../../sceneryPhet.js';
Expand Down Expand Up @@ -155,6 +155,9 @@ export default class KeyboardHelpSection extends ReadingBlock( VBox ) {

const readingBlockResponseProperty = this.createReadingBlockResponseProperty();
this.setReadingBlockNameResponse( readingBlockResponseProperty );

// Decorating with additional content is an anti-pattern, see https://github.com/phetsims/sun/issues/860
assert && assertNoAdditionalChildren( this );
}

/**
Expand Down

0 comments on commit f337fd3

Please sign in to comment.