• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kommitters / editorjs-toggle-block / 10892436159

16 Sep 2024 09:37PM UTC coverage: 30.939% (-1.2%) from 32.139%
10892436159

Pull #243

github

web-flow
Merge 1c88c2761 into 152a5cd00
Pull Request #243: General decoupling in functions

73 of 367 branches covered (19.89%)

Branch coverage included in aggregate %.

77 of 456 new or added lines in 24 files covered. (16.89%)

4 existing lines in 1 file now uncovered.

250 of 677 relevant lines covered (36.93%)

29.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/blocks/hideAndShowBlocks.js
1
/**
2
* Hides and shows the toggle paragraphs or the default content.
3
* If the toggle status is closed, the added value to the hidden attribute
4
* in the container paragraph is 'true', otherwise is 'false'.
5
*
6
* @param {number} index - toggle index
7
*/
8

9
export default function hideAndShowBlocks(foreignKey = this.wrapper.id, value = this.data.status) {
×
NEW
10
  const children = document.querySelectorAll(
×
11
    `div[foreignKey="${foreignKey}"]`,
12
  );
NEW
13
  const { length } = children;
×
14

NEW
15
  if (length > 0) {
×
NEW
16
    children.forEach((child) => {
×
NEW
17
      child.hidden = value === 'closed';
×
18

19
      // Check if this child is a toggle and hide his children too
NEW
20
      const toggles = child.querySelectorAll('.toggle-block__selector');
×
NEW
21
      const isToggle = toggles.length > 0;
×
NEW
22
      if (isToggle) {
×
NEW
23
        const childValue = value === 'closed' ? value : child.getAttribute('status');
×
NEW
24
        hideAndShowBlocks(toggles[0].getAttribute('id'), childValue);
×
25
      }
26
    });
NEW
27
  } else if (foreignKey === this.wrapper.id) {
×
NEW
28
    const { lastChild } = this.wrapper;
×
NEW
29
    lastChild.classList.toggle('toggle-block__hidden', value);
×
30
  }
31
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc