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

SAP / ui5-webcomponents-react / 14974207177

12 May 2025 01:58PM CUT coverage: 87.827% (-0.4%) from 88.18%
14974207177

Pull #7327

github

web-flow
Merge a9e21cb3e into b5963be79
Pull Request #7327: fix(SelectDialog): use `headerText` as `accessibleName` per default

2893 of 3894 branches covered (74.29%)

5072 of 5775 relevant lines covered (87.83%)

107705.4 hits per line

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

95.65
/packages/main/src/internal/utils.ts
1
import {
2
  getCustomElementsScopingSuffix,
3
  getEffectiveScopingSuffixForTag,
4
  getScopedVarName
5
} from '@ui5/webcomponents-base/dist/CustomElementsScope.js';
6
import type { ReactNode } from 'react';
7
import { Children, cloneElement, Fragment } from 'react';
8

9
export function flattenFragments<T = ReactNode>(children: T | T[], depth = 1): T[] {
355✔
10
  const flatChildren = [];
722✔
11
  const removeFragments = (element, level = 0, key = []) => {
722✔
12
    if (!element) {
4,304✔
13
      return;
196✔
14
    }
15
    if (Array.isArray(element)) {
4,108✔
16
      Children.toArray(element).forEach((child, index) => {
331✔
17
        removeFragments(child, level + 1, [...key, index]);
1,442✔
18
      });
19
      return;
331✔
20
    }
21
    if (element.type === Fragment && level <= depth) {
3,777✔
22
      Children.toArray(element.props?.children).forEach((item, index) => {
689✔
23
        removeFragments(item, level + 1, [...key, index]);
2,140✔
24
      });
25
    } else if (typeof element === 'string' || typeof element === 'number') {
3,088!
26
      flatChildren.push(element);
×
27
    } else {
28
      flatChildren.push(cloneElement(element, { key: key.join('.') }));
3,088✔
29
    }
30
  };
31
  removeFragments(children);
722✔
32

33
  return flatChildren;
722✔
34
}
35

36
export function getUi5TagWithSuffix(baseTagName) {
37
  const tagNameSuffix: string = getEffectiveScopingSuffixForTag(baseTagName);
5,273✔
38
  return tagNameSuffix ? `${baseTagName}-${tagNameSuffix}` : baseTagName;
5,273!
39
}
40

41
export const isSSR = () => typeof window === 'undefined';
413✔
42

43
export function trimAndRemoveSpaces(value) {
44
  return value.trim().replace(/\s\s+/g, ' ');
756✔
45
}
46

47
export const cssVarVersionInfoPrefix = getScopedVarName('--_ui5_').replace('--_ui5_', '');
413✔
48

49
export function getTagNameWithoutScopingSuffix(tagName) {
50
  const tagNameSuffix = getCustomElementsScopingSuffix();
2,091✔
51
  return tagNameSuffix ? tagName.replace(`-${tagNameSuffix.toUpperCase()}`, '') : tagName;
2,091!
52
}
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