1/** 2 * TablePress aria-labelledby propagation 3 * 4 * Divi's Custom Attributes UI only adds attributes to the module's wrapper 5 * <div>, not to the inner content. For a11y, aria-labelledby needs to be on 6 * the <table> element itself â placing it on a generic wrapper <div> with no 7 * role causes screen readers to ignore it. This script copies the wrapper's 8 * aria-labelledby down to the actual <table> inside it. 9 * 10 * Scope is intentionally narrow: it only targets <table> elements whose id 11 * starts with "tablepress-" (TablePress's own naming convention). Other 12 * tables â Divi's native Table module, hand-coded HTML â are untouched. 13 * 14 * Usage: in Divi Theme Builder, on a Code module that contains a TablePress 15 * shortcode, add Custom Attribute aria-labelledby="some-id" referencing the 16 * heading wrapper's id. This script does the rest. 17 */ 18(function () { 19 function init() { 20 document.querySelectorAll('.et_pb_code[aria-labelledby]').forEach(function (wrapper) { 21 const table = wrapper.querySelector('table[id^="tablepress-"]'); 22 if (table && !table.hasAttribute('aria-labelledby')) { 23 table.setAttribute('aria-labelledby', wrapper.getAttribute('aria-labelledby')); 24 } 25 }); 26 } 27 28 if (document.readyState === 'loading') { 29 document.addEventListener('DOMContentLoaded', init); 30 } else { 31 init(); 32 } 33})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.