MCPcopy Index your code
hub / github.com/bytecodealliance/component-docs / changeTab

Function changeTab

component-model/theme/tabs.js:7–33  ·  view source on GitHub ↗
(container, name)

Source from the content-addressed store, hash-verified

5 * @param {string} name
6 */
7const changeTab = (container, name) => {
8 for (const child of container.children) {
9 if (!(child instanceof HTMLElement)) {
10 continue;
11 }
12
13 if (child.classList.contains('mdbook-tabs')) {
14 for (const tab of child.children) {
15 if (!(tab instanceof HTMLElement)) {
16 continue;
17 }
18
19 if (tab.dataset.tabname === name) {
20 tab.classList.add('active');
21 } else {
22 tab.classList.remove('active');
23 }
24 }
25 } else if (child.classList.contains('mdbook-tab-content')) {
26 if (child.dataset.tabname === name) {
27 child.classList.remove('hidden');
28 } else {
29 child.classList.add('hidden');
30 }
31 }
32 }
33};
34
35document.addEventListener('DOMContentLoaded', () => {
36 const tabs = document.querySelectorAll('.mdbook-tab');

Callers 1

tabs.jsFile · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…