diff --git a/paper-toast.js b/paper-toast.js index 213af6c..fb0cd44 100644 --- a/paper-toast.js +++ b/paper-toast.js @@ -163,7 +163,15 @@ Polymer({ * Set to true to disable auto-focusing the toast or child nodes with * the `autofocus` attribute` when the overlay is opened. */ - noAutoFocus: {type: Boolean, value: true} + noAutoFocus: {type: Boolean, value: true}, + + /** + * Set to true to prevent paper-toast from dispatching 'iron-announce' + * events. (`` updates an `aria-live` region in + * response to these events, causing the region to be automatically read by + * screen readers.) + */ + noIronAnnounce: {type: Boolean, value: false}, }, listeners: {'transitionend': '__onTransitionEnd'}, @@ -254,7 +262,9 @@ Polymer({ currentToast.close(); } currentToast = this; - this.fire('iron-announce', {text: this.text}); + if (!this.noIronAnnounce) { + this.fire('iron-announce', {text: this.text}); + } if (this._canAutoClose) { this._autoClose = this.async(this.close, this.duration); } diff --git a/test/basic.html b/test/basic.html index a638b23..c538ec3 100644 --- a/test/basic.html +++ b/test/basic.html @@ -236,6 +236,15 @@ 'text announced'); }); + test('show() will not announce text if noIronAnnounce is set', function() { + toast = fixture('basic'); + toast.noIronAnnounce = true; + var spy = sinon.spy(toast, 'fire'); + toast.text = 'announce!'; + toast.show(); + assert.isFalse(spy.called, 'text announced'); + }); + test('hide() will not announce text', function() { toast = fixture('show'); var spy = sinon.spy(toast, 'fire');