@wordpress/a11y
Version:
Accessibility (a11y) utilities for WordPress.
44 lines (42 loc) • 1.7 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/a11y/src/script/add-container.ts
var add_container_exports = {};
__export(add_container_exports, {
default: () => addContainer
});
module.exports = __toCommonJS(add_container_exports);
function addContainer(ariaLive = "polite") {
const container = document.createElement("div");
container.id = `a11y-speak-${ariaLive}`;
container.className = "a11y-speak-region";
container.setAttribute(
"style",
"position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);border:0;word-wrap:normal !important;word-break:normal !important;"
);
container.setAttribute("aria-live", ariaLive);
container.setAttribute("aria-relevant", "additions text");
container.setAttribute("aria-atomic", "true");
const { body } = document;
if (body) {
body.appendChild(container);
}
return container;
}
//# sourceMappingURL=add-container.cjs.map