malinajs 0.7.12 → 0.7.13

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/malina.js +38 -13
  2. package/package.json +1 -1
package/malina.js CHANGED
@@ -406,6 +406,18 @@
406
406
  xNode(data, handler)
407
407
  xNode(handler)
408
408
  xNode(xNode, data, handler)
409
+
410
+ $wait - wait for a node be processed
411
+ $hold - hold a node from processing
412
+
413
+ xNode('name', {
414
+ $wait: ['apply', 'rootCD', anotherNode],
415
+ $hold: ['apply', 'anotherNode']
416
+ }, (ctx, node) => {
417
+ this.inuse.apply // check if apply is used
418
+ this.inuse.rootCD // check if rootCD is used
419
+ node.$wait[0].value // check value of first node in $wait
420
+ })
409
421
  */
410
422
  if(_type instanceof xNode) {
411
423
  let n = _type;
@@ -5109,8 +5121,7 @@
5109
5121
  if(name[0] == '#') {
5110
5122
  assert(!value, 'Wrong ref');
5111
5123
  name = name.substring(1);
5112
- assert(isSimpleName(name), name);
5113
- this.checkRootName(name);
5124
+ assert(detectExpressionType(name) == 'identifier', name);
5114
5125
  reference = name;
5115
5126
  return;
5116
5127
  } else if(name[0] == ':' || name.startsWith('bind:')) {
@@ -6017,19 +6028,26 @@
6017
6028
  if(block.singleBlock) {
6018
6029
  itemBlock = xNode('each-component', {
6019
6030
  block: block.singleBlock,
6031
+ reference: block.reference,
6020
6032
  rebind,
6021
6033
  itemName,
6022
6034
  indexName
6023
6035
  }, (ctx, n) => {
6024
6036
  ctx.write(`$runtime.makeEachSingleBlock((${n.itemName}`);
6025
- if(n.indexName) ctx.write(`, ${n.indexName}`);
6037
+ if (n.indexName) ctx.write(`, ${n.indexName}`);
6026
6038
  ctx.write(') => [');
6027
6039
  ctx.indent++;
6028
6040
  ctx.write(true);
6029
- if(n.rebind) ctx.add(n.rebind);
6041
+ if (n.rebind) ctx.add(n.rebind);
6030
6042
  else ctx.write('null');
6031
6043
  ctx.write(',', true);
6032
- ctx.add(n.block);
6044
+ if (n.reference) {
6045
+ ctx.write(true, `(${n.reference} = `);
6046
+ ctx.add(n.block);
6047
+ ctx.write(')', true);
6048
+ } else {
6049
+ ctx.add(n.block);
6050
+ }
6033
6051
  ctx.indent--;
6034
6052
  ctx.write(true, '])');
6035
6053
  });
@@ -6458,13 +6476,20 @@
6458
6476
  ctx.add(n.slot.template);
6459
6477
  ctx.write(')');
6460
6478
  } else {
6461
- ctx.write('$runtime.makeBlockBound(');
6462
- ctx.add(n.slot.template);
6463
- ctx.write(', ($parentElement) => {', true);
6464
- ctx.indent++;
6465
- ctx.add(n.slot.source);
6466
- ctx.indent--;
6467
- ctx.write(true, '})');
6479
+ ctx.add(xNode('make-block', {
6480
+ $wait: ['apply'],
6481
+ template: n.slot.template,
6482
+ source: n.slot.source
6483
+ }, (ctx, n) => {
6484
+ if(this.inuse.apply) ctx.write('$runtime.makeBlockBound(');
6485
+ else ctx.write('$runtime.makeBlock(');
6486
+ ctx.add(n.template);
6487
+ ctx.write(', ($parentElement) => {', true);
6488
+ ctx.indent++;
6489
+ ctx.add(n.source);
6490
+ ctx.indent--;
6491
+ ctx.write(true, '})');
6492
+ }));
6468
6493
  }
6469
6494
  } else missed = ', null';
6470
6495
 
@@ -6854,7 +6879,7 @@
6854
6879
  });
6855
6880
  }
6856
6881
 
6857
- const version = '0.7.12';
6882
+ const version = '0.7.13';
6858
6883
 
6859
6884
 
6860
6885
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.7.12",
3
+ "version": "0.7.13",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "npm run build_runtime && rollup -c",