rmr-util 1.1.138 → 1.1.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/index.html CHANGED
@@ -102,6 +102,10 @@
102
102
  <form class="xhr" action="xhr/form.php" method="get" enctype="application/x-www-form-urlencoded">
103
103
  <input type="checkbox" name="check" value="rmr">
104
104
  <input type="text" name="text" value="" placeholder="text">
105
+ <select multiple name="select">
106
+ <option value="1">1</option>
107
+ <option value="2">2</option>
108
+ </select>
105
109
  <textarea name="textarea" placeholder="text"></textarea>
106
110
  <button class="">Submit</button>
107
111
  </form>
package/index.js CHANGED
@@ -915,16 +915,11 @@
915
915
  return {};
916
916
  }
917
917
 
918
- if (typeof FormData !== 'undefined') {
919
- // const f = new FormData(form);
920
- // console.log(f);
921
- // return f;
922
- }
923
918
 
924
919
  const
925
920
  inputs = form.querySelectorAll('select,input,textarea'),
926
921
  params = {};
927
-
922
+ //
928
923
  for (const i in inputs) {
929
924
  if (! objectHas(inputs, i)) {
930
925
  continue;
@@ -933,7 +928,7 @@
933
928
  name = inputs[i].getAttribute('name'),
934
929
  type = inputs[i].type ? inputs[i].type : 'text';
935
930
 
936
- if (inputs[i].hasAttribute('disabled')) {
931
+ if (inputs[i].hasAttribute('disabled') || !name) {
937
932
  continue;
938
933
  }
939
934
 
@@ -941,6 +936,15 @@
941
936
  if (inputs[i].checked) {
942
937
  params[name] = inputs[i].value;
943
938
  }
939
+ } else if ((type === 'select' || type === 'select-multiple') && inputs[i].hasAttribute('multiple')) {
940
+
941
+ let arr = [];
942
+ const opts = inputs[i].querySelectorAll('option:checked');
943
+ opts.forEach((o) => {
944
+ arr.push(o.value);
945
+ });
946
+ params[name] = arr;
947
+
944
948
  } else {
945
949
  params[name] = inputs[i].value;
946
950
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rmr-util",
3
- "version": "1.1.138",
3
+ "version": "1.1.140",
4
4
  "description": "JS & CSS for your browser",
5
5
  "url": "https://davidfmiller.github.io/rmr-util/",
6
6
  "license": "ISC",