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AU,EAAE;mBAKE,QAAQ,EAAE;mBAAE,MAAM,CAAC,4BAA4B,CAAC;;uBALlD;IA2Cb,sBAAC;AAAD,CA1CA,AA0CC,IAAA","file":"core/a11y/live-announcer.js","sourcesContent":["import {\n Injectable,\n OpaqueToken,\n Optional,\n Inject\n} from '@angular/core';\n\nexport const LIVE_ANNOUNCER_ELEMENT_TOKEN = new OpaqueToken('mdLiveAnnouncerElement');\n\nexport type AriaLivePoliteness = 'off' | 'polite' | 'assertive';\n\n@Injectable()\nexport class MdLiveAnnouncer {\n\n private _liveElement: Element;\n\n constructor(@Optional() @Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN) elementToken: any) {\n\n // We inject the live element as `any` because the constructor signature cannot reference\n // browser globals (HTMLElement) on non-browser environments, since having a class decorator\n // causes TypeScript to preserve the constructor signature types.\n this._liveElement = elementToken || this._createLiveElement();\n }\n\n /**\n * @param message Message to be announced to the screenreader\n * @param politeness The politeness of the announcer element.\n */\n announce(message: string, politeness: AriaLivePoliteness = 'polite'): void {\n this._liveElement.textContent = '';\n\n // TODO: ensure changing the politeness works on all environments we support.\n this._liveElement.setAttribute('aria-live', politeness);\n\n // This 100ms timeout is necessary for some browser + screen-reader combinations:\n // - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.\n // - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a\n // second time without clearing and then using a non-zero delay.\n // (using JAWS 17 at time of this writing).\n setTimeout(() => this._liveElement.textContent = message, 100);\n }\n\n private _createLiveElement(): Element {\n let liveEl = document.createElement('div');\n\n liveEl.classList.add('md-live-announcer');\n liveEl.setAttribute('aria-atomic', 'true');\n liveEl.setAttribute('aria-live', 'polite');\n\n document.body.appendChild(liveEl);\n\n return liveEl;\n }\n\n}\n"],"sourceRoot":"/source/"}
\No newline at end of file