UNPKG

@wordpress/a11y

Version:
35 lines (33 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = addIntroText; var _i18n = require("@wordpress/i18n"); /** * WordPress dependencies */ /** * Build the explanatory text to be placed before the aria live regions. * * This text is initially hidden from assistive technologies by using a `hidden` * HTML attribute which is then removed once a message fills the aria-live regions. * * @return {HTMLParagraphElement} The explanatory text HTML element. */ function addIntroText() { const introText = document.createElement('p'); introText.id = 'a11y-speak-intro-text'; introText.className = 'a11y-speak-intro-text'; introText.textContent = (0, _i18n.__)('Notifications'); introText.setAttribute('style', 'position:absolute;' + 'margin:-1px;' + 'padding:0;' + 'height:1px;' + 'width:1px;' + 'overflow:hidden;' + 'clip-path:inset(50%);' + 'border:0;' + 'word-wrap:normal !important;'); introText.setAttribute('hidden', ''); const { body } = document; if (body) { body.appendChild(introText); } return introText; } //# sourceMappingURL=add-intro-text.js.map