Do not serialize empty values for state and pipe

Change-Id: I641774560d2465c2a85d74d5d5b6f312861ff539
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 7be0a13..1796c6a 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -504,6 +504,18 @@
           input.removeAttribute('name');
         };
 
+        if (KorAP.States != null) {
+          const statesE = KorAP.States.element();
+          if (statesE.value == "")
+            statesE.removeAttribute('name');
+        };
+        
+        if (KorAP.Pipe != null) {
+          const pipeE = KorAP.Pipe.element();
+          if (pipeE.value == "")
+            pipeE.removeAttribute("name");
+        };
+
         // This would preferably set the query to be "disabled",
         // but in that case the query wouldn't be submitted
         // at all.
@@ -511,6 +523,13 @@
         // of webkit.
         qf.classList.add("loading");
         d.getElementById('qsubmit').classList.add("loading");
+
+        // Alternatively the submission could be prevented early
+        // and the formData API could be used instead:
+        // e.preventDefault();
+        // const formData = new FormData(this);
+        // const queryString = new URLSearchParams(formData).toString();
+        // window.location.href = `${this.action}?${queryString}`;
       });
     };
  
diff --git a/dev/js/src/state/manager.js b/dev/js/src/state/manager.js
index 136310b..d62827a 100644
--- a/dev/js/src/state/manager.js
+++ b/dev/js/src/state/manager.js
@@ -39,6 +39,10 @@
       this._states = JSON.parse('{' + value + '}');
     },
 
+    // Return element
+    element : function() {
+      return this._e;
+    },
 
     // Return the string representation of all states
     toString : function () {