[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> a11y.js (source)

   1  (function() {
   2  "use strict";
   3  var wp;
   4  (wp ||= {}).a11y = (() => {
   5    var __create = Object.create;
   6    var __defProp = Object.defineProperty;
   7    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   8    var __getOwnPropNames = Object.getOwnPropertyNames;
   9    var __getProtoOf = Object.getPrototypeOf;
  10    var __hasOwnProp = Object.prototype.hasOwnProperty;
  11    var __commonJS = (cb, mod) => function __require() {
  12      return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  13    };
  14    var __export = (target, all) => {
  15      for (var name in all)
  16        __defProp(target, name, { get: all[name], enumerable: true });
  17    };
  18    var __copyProps = (to, from, except, desc) => {
  19      if (from && typeof from === "object" || typeof from === "function") {
  20        for (let key of __getOwnPropNames(from))
  21          if (!__hasOwnProp.call(to, key) && key !== except)
  22            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  23      }
  24      return to;
  25    };
  26    var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  27      // If the importer is in node compatibility mode or this is not an ESM
  28      // file that has been converted to a CommonJS file using a Babel-
  29      // compatible transform (i.e. "__esModule" has not been set), then set
  30      // "default" to the CommonJS "module.exports" for node compatibility.
  31      isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  32      mod
  33    ));
  34    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  35  
  36    // package-external:@wordpress/dom-ready
  37    var require_dom_ready = __commonJS({
  38      "package-external:@wordpress/dom-ready"(exports, module) {
  39        module.exports = window.wp.domReady;
  40      }
  41    });
  42  
  43    // package-external:@wordpress/i18n
  44    var require_i18n = __commonJS({
  45      "package-external:@wordpress/i18n"(exports, module) {
  46        module.exports = window.wp.i18n;
  47      }
  48    });
  49  
  50    // packages/a11y/build-module/index.mjs
  51    var index_exports = {};
  52    __export(index_exports, {
  53      setup: () => setup,
  54      speak: () => speak
  55    });
  56    var import_dom_ready = __toESM(require_dom_ready(), 1);
  57  
  58    // packages/a11y/build-module/script/add-container.mjs
  59    function addContainer(ariaLive = "polite") {
  60      const container = document.createElement("div");
  61      container.id = `a11y-speak-$ariaLive}`;
  62      container.className = "a11y-speak-region";
  63      container.setAttribute(
  64        "style",
  65        "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;"
  66      );
  67      container.setAttribute("aria-live", ariaLive);
  68      container.setAttribute("aria-relevant", "additions text");
  69      container.setAttribute("aria-atomic", "true");
  70      const { body } = document;
  71      if (body) {
  72        body.appendChild(container);
  73      }
  74      return container;
  75    }
  76  
  77    // packages/a11y/build-module/script/add-intro-text.mjs
  78    var import_i18n = __toESM(require_i18n(), 1);
  79    function addIntroText() {
  80      const introText = document.createElement("p");
  81      introText.id = "a11y-speak-intro-text";
  82      introText.className = "a11y-speak-intro-text";
  83      introText.textContent = (0, import_i18n.__)("Notifications");
  84      introText.setAttribute(
  85        "style",
  86        "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;"
  87      );
  88      introText.setAttribute("hidden", "");
  89      const { body } = document;
  90      if (body) {
  91        body.appendChild(introText);
  92      }
  93      return introText;
  94    }
  95  
  96    // packages/a11y/build-module/shared/clear.mjs
  97    function clear() {
  98      const regions = document.getElementsByClassName("a11y-speak-region");
  99      const introText = document.getElementById("a11y-speak-intro-text");
 100      for (let i = 0; i < regions.length; i++) {
 101        regions[i].textContent = "";
 102      }
 103      if (introText) {
 104        introText.setAttribute("hidden", "hidden");
 105      }
 106    }
 107  
 108    // packages/a11y/build-module/shared/filter-message.mjs
 109    var previousMessage = "";
 110    function filterMessage(message) {
 111      message = message.replace(/<[^<>]+>/g, " ");
 112      if (previousMessage === message) {
 113        message += "\xA0";
 114      }
 115      previousMessage = message;
 116      return message;
 117    }
 118  
 119    // packages/a11y/build-module/shared/index.mjs
 120    function speak(message, ariaLive) {
 121      clear();
 122      message = filterMessage(message);
 123      const introText = document.getElementById("a11y-speak-intro-text");
 124      const containerAssertive = document.getElementById(
 125        "a11y-speak-assertive"
 126      );
 127      const containerPolite = document.getElementById("a11y-speak-polite");
 128      if (containerAssertive && ariaLive === "assertive") {
 129        containerAssertive.textContent = message;
 130      } else if (containerPolite) {
 131        containerPolite.textContent = message;
 132      }
 133      if (introText) {
 134        introText.removeAttribute("hidden");
 135      }
 136    }
 137  
 138    // packages/a11y/build-module/index.mjs
 139    function setup() {
 140      const introText = document.getElementById("a11y-speak-intro-text");
 141      const containerAssertive = document.getElementById(
 142        "a11y-speak-assertive"
 143      );
 144      const containerPolite = document.getElementById("a11y-speak-polite");
 145      if (introText === null) {
 146        addIntroText();
 147      }
 148      if (containerAssertive === null) {
 149        addContainer("assertive");
 150      }
 151      if (containerPolite === null) {
 152        addContainer("polite");
 153      }
 154    }
 155    (0, import_dom_ready.default)(setup);
 156    return __toCommonJS(index_exports);
 157  })();
 158  (window.wp ||= {}).a11y = wp.a11y;
 159  })();


Generated : Wed Aug 26 08:20:24 2026 Cross-referenced by PHPXref