@daz4126/helium 0.19.0 → 0.20.0

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.
Files changed (2) hide show
  1. package/helium.js +10 -6
  2. package/package.json +1 -1
package/helium.js CHANGED
@@ -34,11 +34,11 @@ window.helium = function() {
34
34
 
35
35
  const update = (data,target,action,template) => {
36
36
  const element = target instanceof Node ? target : (HELIUM.refs.get(target) || $(target));
37
- if(element){
38
- const content = html(template ? template(data) : data);
39
- action ? element[action=="replace"?"replaceWith":action](content) : element.innerHTML = content;
40
- return content
41
- } else state[target] = data
37
+ if(element){
38
+ const content = html(template ? template(data) : data);
39
+ action ? element[action=="replace"?"replaceWith":action](content) : element.innerHTML = content;
40
+ return content
41
+ } else state[target] = data
42
42
  }
43
43
 
44
44
  const ajax = (u,m,o={},p={}) => {
@@ -297,8 +297,12 @@ function processElements(element) {
297
297
  let paramsAttr = getAttr("params");
298
298
  if (!paramsAttr && el.hasAttribute("name")) {
299
299
  const keys = el.getAttribute("name").match(/\w+/g).map(key => `${key}:`).join``;
300
- paramsAttr = keys + isCheckbox ? "checked" : "value";
300
+ paramsAttr = keys + (isCheckbox ? "checked" : "value");
301
301
  } else paramsAttr ||= "{}";
302
+ if (!paramsAttr.trim().startsWith("{") && paramsAttr.includes(":")) {
303
+ const props = paramsAttr.split(":").map(s => s.trim());
304
+ paramsAttr = props.reduceRight((acc, key, i) => `{ ${key}: ${i == 1 ? `'${el[acc]}'` : acc} }`);
305
+ }
302
306
  const params = exFn(paramsAttr);
303
307
  ajax(value, eventName.toUpperCase(), options, params);
304
308
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daz4126/helium",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "main": "helium.js",
5
5
  "type": "module",
6
6
  "scripts": {