diff --git a/js/accessibility/AccessibleValueHandler.js b/js/accessibility/AccessibleValueHandler.js index 9310aa3b..c9e2c7b0 100644 --- a/js/accessibility/AccessibleValueHandler.js +++ b/js/accessibility/AccessibleValueHandler.js @@ -26,9 +26,7 @@ define( require => { const KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); const Node = require( 'SCENERY/nodes/Node' ); const Property = require( 'AXON/Property' ); - const StringUtils = require( 'PHETCOMMON/util/StringUtils' ); const sun = require( 'SUN/sun' ); - const SunConstants = require( 'SUN/SunConstants' ); const Util = require( 'DOT/Util' ); const Utterance = require( 'SCENERY_PHET/accessibility/Utterance' ); const utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' ); @@ -64,28 +62,12 @@ define( require => { */ initializeAccessibleValueHandler( valueProperty, rangeProperty, enabledProperty, options ) { - // ensure that the client does not set both a custom text pattern and a text creation function - assert && assert( - !( options.a11yValuePattern && options.a11yCreateAriaValueText ), - 'cannot set both a11yValuePattern and a11yCreateAriaValueText in options' - ); - // if rounding to keyboard step, keyboardStep must be defined so values aren't skipped and the slider // doesn't get stuck while rounding to the nearest value, see https://github.com/phetsims/sun/issues/410 if ( assert && options.roundToStepSize ) { assert( options.keyboardStep, 'rounding to keyboardStep, define appropriate keyboardStep to round to' ); } - // verify that a11yValuePattern includes SunConstants.VALUE_NAMED_PLACEHOLDER, and that is the only key in the pattern - if ( assert && options.a11yValuePattern ) { - assert( options.a11yValuePattern.match( /{{[^{}]+}}/g ).length === 1, - 'a11yValuePattern only accepts a single \'value\' key' - ); - assert( options.a11yValuePattern.indexOf( SunConstants.VALUE_NAMED_PLACEHOLDER ) >= 0, - 'a11yValuePattern must contain a key of \'value\'' - ); - } - const defaults = { // other @@ -101,7 +83,6 @@ define( require => { // TODO: this should be an enumeration, https://github.com/phetsims/gravity-force-lab-basics/issues/134 ariaOrientation: 'horizontal', // specify orientation, read by assistive technology - a11yValuePattern: SunConstants.VALUE_NAMED_PLACEHOLDER, // {string} if you want units or additional content, add to pattern a11yDecimalPlaces: 0, // number of decimal places for the value when formatted and read by assistive technology // {boolean} - Whether or not to round the value to a multiple of the keyboardStep. This will only round @@ -126,8 +107,7 @@ define( require => { a11yRepeatEqualValueText: true, /** - * Custom aria-valuetext creation function, called when the valueProperty changes. Used in replacement of - * the simpler/easier option: a11yValuePattern. + * aria-valuetext creation function, called when the valueProperty changes. * This string is read by AT every time the slider value changes. * @type {Function} * @param {number} formattedValue - mapped value fixed to the provided decimal places @@ -258,9 +238,6 @@ define( require => { // @private {function} this.a11yMapValue = options.a11yMapValue; - // @private {function} - this.a11yValuePattern = options.a11yValuePattern; - // @private {function} this.a11yCreateAriaValueText = options.a11yCreateAriaValueText; @@ -342,11 +319,8 @@ define( require => { updateAriaValueText( oldPropertyValue ) { const formattedValue = this.getA11yFormattedValue(); - // create the final string from optional parameters. Only the valuePattern OR the create function can be - // specified (see above assertions). - let newAriaValueText = StringUtils.fillIn( this.a11yValuePattern, { - value: this.a11yCreateAriaValueText( formattedValue, this._valueProperty.value, oldPropertyValue ) - } ); + // create the dynamic aria-valuetext from a11yCreateAriaValueText. + let newAriaValueText = this.a11yCreateAriaValueText( formattedValue, this._valueProperty.value, oldPropertyValue ); if ( this._a11yRepeatEqualValueText && newAriaValueText === this.ariaValueText ) {