From c2b6ad42b2903c21c03d699e4572e98bdbe757bc Mon Sep 17 00:00:00 2001 From: Jesse Date: Fri, 15 Apr 2022 20:16:30 -0400 Subject: [PATCH] remove the default TinyProperty in canAnnounceProperties, see https://github.com/phetsims/utterance-queue/issues/79 --- js/Utterance.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/Utterance.ts b/js/Utterance.ts index 8ec0beb..2a5acc5 100644 --- a/js/Utterance.ts +++ b/js/Utterance.ts @@ -128,7 +128,7 @@ class Utterance { const options = optionize( { alert: null, predicate: function() { return true; }, - canAnnounceProperties: [ new TinyProperty( true ) ], + canAnnounceProperties: [], alertStableDelay: 200, alertMaximumDelay: Number.MAX_VALUE, announcerOptions: {}, @@ -232,13 +232,14 @@ class Utterance { * this.canAnnounceProperty. */ public setCanAnnounceProperties( canAnnounceProperties: IProperty[] ): void { - assert && assert( canAnnounceProperties.length > 0, 'There must be at least once dependency canAnnounceProperty' ); - if ( this.canAnnounceImplementationProperty.value ) { this.canAnnounceImplementationProperty.value.dispose(); } - const canSpeakProperty = DerivedProperty.and( canAnnounceProperties ); + // If no canAnnounceProperties provided, use a dummy Property that will always allow this Utterance to announce. + const dependencyProperties = canAnnounceProperties.length === 0 ? [ new TinyProperty( true ) ] : canAnnounceProperties; + + const canSpeakProperty = DerivedProperty.and( dependencyProperties ); this.canAnnounceImplementationProperty.value = canSpeakProperty; this._canAnnounceProperties = canAnnounceProperties;