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

atomicpages / pretty-checkbox-react / 8915003455

01 May 2024 09:07PM UTC coverage: 100.0%. Remained the same
8915003455

Pull #1098

github

web-flow
build(deps): bump ejs from 3.1.6 to 3.1.10 in /docs

Bumps [ejs](https://github.com/mde/ejs) from 3.1.6 to 3.1.10.
- [Release notes](https://github.com/mde/ejs/releases)
- [Commits](https://github.com/mde/ejs/compare/v3.1.6...v3.1.10)

---
updated-dependencies:
- dependency-name: ejs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1098: build(deps): bump ejs from 3.1.6 to 3.1.10 in /docs

67 of 67 branches covered (100.0%)

Branch coverage included in aggregate %.

172 of 172 relevant lines covered (100.0%)

9.99 hits per line

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

100.0
/src/components/switch/useAriaChecked.ts
1
import * as React from 'react';
2✔
2
import { PCRSwitchProps } from '../../typings/PCRSwitchProps';
3

4
export type UseAriaCheckedOptions = {
5
  setState?: PCRSwitchProps['setState'];
6
  checked?: PCRSwitchProps['checked'];
7
};
8

9
const handler = (e: any) => {
2✔
10
  e.currentTarget.setAttribute('aria-checked', e.currentTarget.checked + '');
2✔
11
};
12

13
/**
14
 * A small hook to help manage correct aria-checked state when switch
15
 * is used as an uncontrolled component. We need this to run
16
 * for a11y purposes. FOr the `switch` role, `aria-checked` is required.
17
 */
18
export const useAriaChecked = ({
2✔
19
  setState,
20
  checked,
21
}: UseAriaCheckedOptions) => {
22
  const ref = React.useRef<HTMLInputElement>(null);
7✔
23

24
  React.useEffect(() => {
7✔
25
    const elem = ref.current;
7✔
26
    let bound = false;
7✔
27

28
    if (!setState && !checked && elem) {
7✔
29
      elem.setAttribute('aria-checked', elem.checked + '');
4✔
30
      elem.addEventListener('change', handler);
4✔
31
      bound = true;
4✔
32
    }
33

34
    return () => {
7✔
35
      if (bound && elem) {
7✔
36
        elem.removeEventListener('change', handler);
4✔
37
      }
38
    };
39
  }, [setState, checked]);
40

41
  return ref;
7✔
42
};
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

© 2025 Coveralls, Inc