MCPcopy Create free account
hub / github.com/bytecodealliance/component-docs / initContainer

Function initContainer

component-model/theme/tabs-a11y.js:14–45  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

12 }
13
14 function initContainer(container) {
15 const nav = container.querySelector('.mdbook-tabs');
16 if (nav && !nav.hasAttribute('role')) {
17 nav.setAttribute('role', 'tablist');
18 }
19
20 const tabs = Array.from(container.querySelectorAll('.mdbook-tab'));
21 const panes = Array.from(container.querySelectorAll('.mdbook-tab-content'));
22
23 tabs.forEach(function (tab) {
24 if (tab.hasAttribute('role')) return;
25 const uid = nextUid();
26 const tabId = 'mdbook-tab-' + uid;
27 const paneId = 'mdbook-tabpanel-' + uid;
28
29 tab.setAttribute('role', 'tab');
30 tab.id = tabId;
31
32 const pane = panes.find(function (p) {
33 return p.dataset.tabname === tab.dataset.tabname;
34 });
35 if (pane) {
36 pane.setAttribute('role', 'tabpanel');
37 pane.id = paneId;
38 if (!pane.hasAttribute('tabindex')) {
39 pane.setAttribute('tabindex', '0');
40 }
41 tab.setAttribute('aria-controls', paneId);
42 pane.setAttribute('aria-labelledby', tabId);
43 }
44 });
45 }
46
47 function syncContainer(container) {
48 container.querySelectorAll('.mdbook-tab').forEach(function (tab) {

Callers

nothing calls this directly

Calls 1

nextUidFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…