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

adobe / spectrum-web-components / 17993898764

25 Sep 2025 01:12AM UTC coverage: 97.919%. First build
17993898764

Pull #5578

github

web-flow
Merge e42e5e247 into dbba86174
Pull Request #5578: chore: update playwright and @web/test-runner dependencies with comprehensive test refactoring

5325 of 5638 branches covered (94.45%)

Branch coverage included in aggregate %.

91 of 93 new or added lines in 8 files covered. (97.85%)

34050 of 34574 relevant lines covered (98.48%)

628.82 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;
383✔
27
        this.host.addController(this);
383✔
28
    }
383✔
29

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

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

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

© 2026 Coveralls, Inc