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

markuplint / markuplint / #3730

pending completion
#3730

push

yusukehirao
Publish

 - markuplint@3.8.0
 - @markuplint/config-presets@3.6.0
 - @markuplint/create-rule-helper@3.8.0
 - @markuplint/file-resolver@3.8.0
 - @markuplint/html-spec@3.7.0
 - @markuplint/ml-config@3.7.0
 - @markuplint/ml-core@3.8.0
 - @markuplint/ml-spec@3.7.0
 - @markuplint/react-spec@3.7.0
 - @markuplint/rule-textlint@3.8.0
 - @markuplint/rules@3.8.0
 - @markuplint/selector@3.7.0
 - @markuplint/test-tools@3.2.0
 - @markuplint/vue-spec@3.7.0
 - @markuplint/playground@2.1.0-alpha.10

4489 of 6591 branches covered (68.11%)

Branch coverage included in aggregate %.

7069 of 9801 relevant lines covered (72.13%)

669.2 hits per line

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

67.57
/packages/@markuplint/selector/src/extended-selector/aria-pseudo-class.ts
1
import type { SelectorResult } from '../types';
2
import type { ARIAVersion } from '@markuplint/ml-spec';
3

4
import { validateAriaVersion, ARIA_RECOMMENDED_VERSION, getAccname } from '@markuplint/ml-spec';
1✔
5

6
/**
7
 * Version Syntax is not support yet.
8
 */
9
export function ariaPseudoClass() {
1✔
10
        return (content: string) =>
111✔
11
                (
3✔
12
                        // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13
                        el: Element,
14
                ): SelectorResult => {
15
                        const aria = ariaPseudoClassParser(content);
3✔
16
                        const name = getAccname(el);
3✔
17
                        switch (aria.type) {
3!
18
                                case 'hasName': {
19
                                        if (name) {
3✔
20
                                                return {
3✔
21
                                                        specificity: [0, 1, 0],
22
                                                        matched: true,
23
                                                        nodes: [el],
24
                                                        has: [],
25
                                                };
26
                                        }
27
                                        return {
×
28
                                                specificity: [0, 1, 0],
29
                                                matched: false,
30
                                        };
31
                                }
32
                                case 'hasNoName': {
33
                                        if (!name) {
×
34
                                                return {
×
35
                                                        specificity: [0, 1, 0],
36
                                                        matched: true,
37
                                                        nodes: [el],
38
                                                        has: [],
39
                                                };
40
                                        }
41
                                        return {
×
42
                                                specificity: [0, 1, 0],
43
                                                matched: false,
44
                                        };
45
                                }
46
                        }
47
                };
48
}
49

50
function ariaPseudoClassParser(syntax: string): {
51
        type: 'hasName' | 'hasNoName';
52
        version?: ARIAVersion;
53
} {
54
        const [_query, _version] = syntax.split('|');
3✔
55
        const query = _query?.replace(/\s+/g, '').toLowerCase();
3!
56
        const version = _version ?? ARIA_RECOMMENDED_VERSION;
3✔
57

58
        if (!validateAriaVersion(version)) {
3!
59
                throw new SyntaxError(`Unsupported ARIA version: ${version}`);
×
60
        }
61

62
        switch (query) {
3!
63
                case 'hasname': {
64
                        return {
3✔
65
                                type: 'hasName',
66
                                version,
67
                        };
68
                }
69
                case 'hasnoname': {
70
                        return {
×
71
                                type: 'hasNoName',
72
                                version,
73
                        };
74
                }
75
        }
76

77
        throw new SyntaxError(`Unsupported syntax: ${syntax}`);
×
78
}
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