malinajs 0.7.3 → 0.7.4

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 (3) hide show
  1. package/malina.js +22 -29
  2. package/package.json +1 -1
  3. package/runtime.js +1 -1
package/malina.js CHANGED
@@ -1340,7 +1340,8 @@
1340
1340
  }
1341
1341
 
1342
1342
 
1343
- const parseBinding = (reader) => {
1343
+ const parseBinding = (source) => {
1344
+ const reader = new Reader(source);
1344
1345
  let start = reader.index;
1345
1346
 
1346
1347
  assert(reader.read() === '{', 'Bind error');
@@ -1383,7 +1384,7 @@
1383
1384
  const raw = reader.sub(start);
1384
1385
  return {
1385
1386
  raw,
1386
- value: raw.substring(1, raw.length - 1),
1387
+ value: raw.substring(1, raw.length - 1).trim(),
1387
1388
  };
1388
1389
  }
1389
1390
  };
@@ -2662,7 +2663,7 @@
2662
2663
  each: option.each,
2663
2664
  parentElement: option.parentElement
2664
2665
  }, (ctx, n) => {
2665
- if(n.each && !ctx.isEmpty(n.innerBlock)) {
2666
+ if(n.each) {
2666
2667
  ctx.write('$runtime.makeEachBlock(');
2667
2668
  } else {
2668
2669
  ctx.write('$runtime.makeBlock(');
@@ -6616,42 +6617,34 @@
6616
6617
  name = toCamelCase(name);
6617
6618
  if(name == 'class') name = '_class';
6618
6619
 
6619
- let rawValue, statical = false;
6620
+ let statical = false;
6620
6621
 
6621
6622
  if(value && value.includes('{')) {
6622
- const pe = this.parseText(value);
6623
- this.detectDependency(pe);
6624
-
6625
- if(pe.parts.length == 1 && pe.parts[0].type == 'exp') {
6626
- let v = pe.parts[0].value;
6627
-
6628
- if(isNumber(v)) {
6629
- value = v;
6630
- rawValue = Number(v);
6631
- statical = true;
6632
- } else if(v == 'true' || v == 'false') {
6633
- value = v;
6634
- rawValue = v == 'true';
6635
- statical = true;
6636
- } else if(v == 'null') {
6637
- value = 'null';
6638
- rawValue = null;
6639
- statical = true;
6640
- }
6623
+ const pe = parseBinding(value);
6624
+ const v = pe.value;
6625
+ this.detectDependency(v);
6626
+
6627
+ if(isNumber(v)) {
6628
+ value = v;
6629
+ statical = true;
6630
+ } else if(v == 'true' || v == 'false') {
6631
+ value = v;
6632
+ statical = true;
6633
+ } else if(v == 'null') {
6634
+ value = 'null';
6635
+ statical = true;
6636
+ } else {
6637
+ value = v;
6641
6638
  }
6642
-
6643
- if(!statical) value = pe.result;
6644
6639
  } else if(value) {
6645
- rawValue = value;
6646
6640
  value = '`' + Q(value) + '`';
6647
6641
  statical = true;
6648
6642
  } else {
6649
- rawValue = true;
6650
6643
  value = 'true';
6651
6644
  statical = true;
6652
6645
  }
6653
6646
 
6654
- return { name, value, rawValue, static: statical, mod };
6647
+ return { name, value, static: statical, mod };
6655
6648
  }
6656
6649
 
6657
6650
  function attachPortal(node) {
@@ -6872,7 +6865,7 @@
6872
6865
  });
6873
6866
  }
6874
6867
 
6875
- const version = '0.7.2-a12';
6868
+ const version = '0.7.4';
6876
6869
 
6877
6870
 
6878
6871
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "npm run build_runtime && rollup -c",
package/runtime.js CHANGED
@@ -998,7 +998,7 @@ const eachDefaultKey = (item, index, array) => isObject(array[0]) ? item : index
998
998
  const makeEachBlock = (fr, fn) => {
999
999
  return (item, index) => {
1000
1000
  let $dom = fr.cloneNode(true);
1001
- return [$dom, fn($dom, item, index)];
1001
+ return [$dom, fn?.($dom, item, index)];
1002
1002
  };
1003
1003
  };
1004
1004