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

adobe / spectrum-web-components / 14094674923

26 Mar 2025 10:27PM CUT 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

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

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

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

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

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

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

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

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

1✔
38
    private resolveLanguage(): void {
1✔
39
        const queryThemeEvent = new CustomEvent<ProvideLang>(
×
40
            'sp-language-context',
×
41
            {
×
42
                bubbles: true,
×
43
                composed: true,
×
44
                detail: {
×
45
                    callback: (lang: string, unsubscribe: () => void) => {
×
46
                        const previous = this.language;
×
47
                        this.language = lang;
×
48
                        this.unsubscribe = unsubscribe;
×
49
                        this.host.requestUpdate(
×
50
                            languageResolverUpdatedSymbol,
×
51
                            previous
×
52
                        );
×
53
                    },
×
54
                },
×
55
                cancelable: true,
×
56
            }
×
57
        );
×
58
        this.host.dispatchEvent(queryThemeEvent);
×
59
    }
×
60
}
1✔
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