From 0fdd1c74f258fce5e30c76d0eae091c0defc9427 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 22 Oct 2018 20:31:43 +0200 Subject: [PATCH] Always define localize func (#1830) --- src/mixins/lit-localize-mixin.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mixins/lit-localize-mixin.ts b/src/mixins/lit-localize-mixin.ts index fdd9cd7a48..3692e98e81 100644 --- a/src/mixins/lit-localize-mixin.ts +++ b/src/mixins/lit-localize-mixin.ts @@ -11,6 +11,8 @@ import { LocalizeMixin, } from "./localize-base-mixin"; +const empty = () => ""; + export const HassLocalizeLitMixin = ( superClass: Constructor ): Constructor => @@ -26,6 +28,12 @@ export const HassLocalizeLitMixin = ( }; } + constructor() { + super(); + // This will prevent undefined errors if called before connected to DOM. + this.localize = empty; + } + public connectedCallback(): void { super.connectedCallback();