| 9 | import type {ReactiveController, ReactiveControllerHost} from 'lit'; |
| 10 | |
| 11 | class LocalizeController implements ReactiveController { |
| 12 | host: ReactiveControllerHost; |
| 13 | |
| 14 | constructor(host: ReactiveControllerHost) { |
| 15 | this.host = host; |
| 16 | } |
| 17 | |
| 18 | private readonly __litLocalizeEventHandler = ( |
| 19 | event: WindowEventMap[typeof LOCALE_STATUS_EVENT] |
| 20 | ) => { |
| 21 | if (event.detail.status === 'ready') { |
| 22 | this.host.requestUpdate(); |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | hostConnected() { |
| 27 | window.addEventListener( |
| 28 | LOCALE_STATUS_EVENT, |
| 29 | this.__litLocalizeEventHandler |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | hostDisconnected() { |
| 34 | window.removeEventListener( |
| 35 | LOCALE_STATUS_EVENT, |
| 36 | this.__litLocalizeEventHandler |
| 37 | ); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Re-render the given LitElement whenever a new active locale has loaded. |
nothing calls this directly
no test coverage detected
searching dependent graphs…