@@ -38,7 +38,7 @@ if (typeof module !== "undefined" && module.exports) {
3838}
3939
4040/* exported
41- canvasPixelRatio, changeImage, closeBlkWidgets, closeWidgets,
41+ announceToScreenReader, canvasPixelRatio, changeImage, closeBlkWidgets, closeWidgets,
4242 delayExecution, displayMsg, doBrowserCheck, docByClass, docByName,
4343 docBySelector, docByTagName, doPublish, doStopVideoCam, doSVG,
4444 doUseCamera, format, getTextWidth, hideDOMLabel, httpGet, httpPost, HttpRequest,
@@ -1456,6 +1456,25 @@ let closeBlkWidgets = name => {
14561456 * @param {*[] } viewArgs - Constructor arguments for the view.
14571457 * @returns {void }
14581458 */
1459+ /**
1460+ * Announces a message to screen readers via a shared aria-live region.
1461+ * Creates the region lazily on first use and reuses it for all subsequent calls.
1462+ * @param {string } msg - The message to announce.
1463+ */
1464+ const announceToScreenReader = msg => {
1465+ let region = document . getElementById ( "mbA11yLiveRegion" ) ;
1466+ if ( ! region ) {
1467+ region = document . createElement ( "div" ) ;
1468+ region . id = "mbA11yLiveRegion" ;
1469+ region . setAttribute ( "role" , "status" ) ;
1470+ region . setAttribute ( "aria-live" , "polite" ) ;
1471+ region . setAttribute ( "aria-atomic" , "true" ) ;
1472+ region . style . cssText =
1473+ "position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;" ;
1474+ document . body . appendChild ( region ) ;
1475+ }
1476+ region . textContent = msg ;
1477+ } ;
14591478let importMembers = ( obj , className , modelArgs , viewArgs ) => {
14601479 /**
14611480 * Adds methods and variables of one class to another class's instance.
@@ -1544,6 +1563,7 @@ if (typeof module !== "undefined" && module.exports) {
15441563 processPluginData,
15451564 processMacroData,
15461565 hideDOMLabel,
1547- displayMsg
1566+ displayMsg,
1567+ announceToScreenReader
15481568 } ;
15491569}
0 commit comments