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

adobe / spectrum-web-components / 14094674923

26 Mar 2025 10:27PM UTC coverage: 86.218% (-11.8%) from 98.002%
14094674923

Pull #5221

github

web-flow
Merge 2a1ea92e7 into 3184c1e6a
Pull Request #5221: RFC | leverage css module imports in components

1737 of 2032 branches covered (85.48%)

Branch coverage included in aggregate %.

14184 of 16434 relevant lines covered (86.31%)

85.29 hits per line

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

93.22
/tools/base/src/condition-attribute-with-id.ts
1
/*
5✔
2
Copyright 2020 Adobe. All rights reserved.
5✔
3
This file is licensed to you under the Apache License, Version 2.0 (the "License");
5✔
4
you may not use this file except in compliance with the License. You may obtain a copy
5✔
5
of the License at http://www.apache.org/licenses/LICENSE-2.0
5✔
6

5✔
7
Unless required by applicable law or agreed to in writing, software distributed under
5✔
8
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
5✔
9
OF ANY KIND, either express or implied. See the License for the specific language
5✔
10
governing permissions and limitations under the License.
5✔
11
*/
5✔
12

5✔
13
export function conditionAttributeWithoutId(
5✔
14
    el: HTMLElement,
1✔
15
    attribute: string,
1✔
16
    ids: string[]
1✔
17
): void {
1✔
18
    const ariaDescribedby = el.getAttribute(attribute);
1✔
19
    let descriptors = ariaDescribedby ? ariaDescribedby.split(/\s+/) : [];
1!
20
    descriptors = descriptors.filter(
1✔
21
        (descriptor) => !ids.find((id) => descriptor === id)
1✔
22
    );
1✔
23
    if (descriptors.length) {
1!
24
        el.setAttribute(attribute, descriptors.join(' '));
×
25
    } else {
1✔
26
        el.removeAttribute(attribute);
1✔
27
    }
1✔
28
}
1✔
29

5✔
30
export function conditionAttributeWithId(
5✔
31
    el: HTMLElement,
10✔
32
    attribute: string,
10✔
33
    id: string | string[]
10✔
34
): () => void {
10✔
35
    const ids = Array.isArray(id) ? id : [id];
10✔
36
    const ariaDescribedby = el.getAttribute(attribute);
10✔
37
    const descriptors = ariaDescribedby ? ariaDescribedby.split(/\s+/) : [];
10!
38
    const hadIds = ids.every((id) => descriptors.indexOf(id) > -1);
10✔
39
    if (hadIds)
10✔
40
        /* c8 ignore next 3 */
5✔
41
        return (): void => {
5✔
42
            return;
5✔
43
        };
5✔
44
    descriptors.push(...ids);
10✔
45
    el.setAttribute(attribute, descriptors.join(' '));
10✔
46
    return () => conditionAttributeWithoutId(el, attribute, ids);
10✔
47
}
10✔
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