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

adobe / spectrum-web-components / 16952396515

14 Aug 2025 12:12AM UTC coverage: 98.026%. First build
16952396515

Pull #5578

github

web-flow
Merge 8ede8981d into 99ab45ea7
Pull Request #5578: chore: update web test runner

5311 of 5618 branches covered (94.54%)

Branch coverage included in aggregate %.

4 of 6 new or added lines in 1 file covered. (66.67%)

33829 of 34310 relevant lines covered (98.6%)

640.61 hits per line

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

94.52
/tools/reactive-controllers/src/LanguageResolution.ts
1
/**
20✔
2
 * Copyright 2025 Adobe. All rights reserved.
20✔
3
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
20✔
4
 * you may not use this file except in compliance with the License. You may obtain a copy
20✔
5
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
20✔
6
 *
20✔
7
 * Unless required by applicable law or agreed to in writing, software distributed under
20✔
8
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20✔
9
 * OF ANY KIND, either express or implied. See the License for the specific language
20✔
10
 * governing permissions and limitations under the License.
20✔
11
 */
20✔
12

20✔
13
import type { ReactiveController, ReactiveElement } from 'lit';
20✔
14
import { ProvideLang } from '@spectrum-web-components/theme';
20✔
15

20✔
16
export const languageResolverUpdatedSymbol = Symbol(
20✔
17
    'language resolver updated'
20✔
18
);
20✔
19

20✔
20
export class LanguageResolutionController implements ReactiveController {
20✔
21
    private host: ReactiveElement;
20✔
22
    language = document.documentElement.lang || navigator.language || 'en-US';
20!
23
    private unsubscribe?: () => void;
20✔
24

20✔
25
    constructor(host: ReactiveElement) {
20✔
26
        this.host = host;
382✔
27
        this.host.addController(this);
382✔
28
    }
382✔
29

20✔
30
    public hostConnected(): void {
20✔
31
        this.resolveLanguage();
382✔
32
    }
382✔
33

20✔
34
    public hostDisconnected(): void {
20✔
35
        this.unsubscribe?.();
382✔
36
    }
382✔
37

20✔
38
    private resolveLanguage(): void {
20✔
39
        try {
382✔
40
            Intl.DateTimeFormat.supportedLocalesOf([this.language]);
382✔
41
        } catch {
382!
NEW
42
            this.language = 'en-US';
×
NEW
43
        }
×
44
        const queryThemeEvent = new CustomEvent<ProvideLang>(
382✔
45
            'sp-language-context',
382✔
46
            {
382✔
47
                bubbles: true,
382✔
48
                composed: true,
382✔
49
                detail: {
382✔
50
                    callback: (lang: string, unsubscribe: () => void) => {
382✔
51
                        const previous = this.language;
93✔
52
                        this.language = lang;
93✔
53
                        this.unsubscribe = unsubscribe;
93✔
54
                        this.host.requestUpdate(
93✔
55
                            languageResolverUpdatedSymbol,
93✔
56
                            previous
93✔
57
                        );
93✔
58
                    },
93✔
59
                },
382✔
60
                cancelable: true,
382✔
61
            }
382✔
62
        );
382✔
63
        this.host.dispatchEvent(queryThemeEvent);
382✔
64
    }
382✔
65
}
20✔
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