From 8215d207c8f9d76cb2588ee1b2b528957d285fad Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio@bekerle.com>
Date: Thu, 14 May 2020 08:12:22 +0200
Subject: [PATCH] Fix name switching (#5)

---
 src/textswitch.js | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/textswitch.js b/src/textswitch.js
index 3ae7232..1bb5236 100644
--- a/src/textswitch.js
+++ b/src/textswitch.js
@@ -59,12 +59,18 @@ export class TextSwitch extends LitElement {
     }
 
     update(changedProperties) {
+        if (this._active === BUTTON1) {
+            this.name = this.name1;
+        } else {
+            this.name = this.name2;
+        }
+
         changedProperties.forEach((oldValue, propName) => {
             if (propName === "name") {
-                if (this[propName] == this.name1) {
+                if (this[propName] === this.name1) {
                     this._active = BUTTON1;
                 }
-                if (this[propName] == this.name2) {
+                if (this[propName] === this.name2) {
                     this._active = BUTTON2;
                 }
             } else if (propName === "_active") {
@@ -76,12 +82,6 @@ export class TextSwitch extends LitElement {
             }
         });
 
-        if (this._active === BUTTON1) {
-            this.name = this.name1;
-        } else {
-            this.name = this.name2;
-        }
-
         super.update(changedProperties);
     }
 
-- 
GitLab