@jinntec/fore 1.10.2 → 1.10.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinntec/fore",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "Fore - declarative user interfaces in plain HTML",
5
5
  "module": "./index.js",
6
6
  "publishConfig": {
package/src/fx-bind.js CHANGED
@@ -63,7 +63,7 @@ export class FxBind extends foreElementMixin(HTMLElement) {
63
63
  init(model) {
64
64
  this.model = model;
65
65
  // console.log('init binding ', this);
66
- this.instanceId = this._getInstanceId();
66
+ this._getInstanceId();
67
67
  this.bindType = this.getModel().getInstance(this.instanceId).type;
68
68
  // console.log('binding type ', this.bindType);
69
69
 
@@ -399,20 +399,40 @@ export class FxBind extends foreElementMixin(HTMLElement) {
399
399
  return result;
400
400
  }
401
401
 
402
- // todo: more elaborated implementation ;)
402
+ /**
403
+ * return the instance id this bind is associated with. Resolves upwards in binds to either find an expr containing
404
+ * and instance() function or if not found return 'default'.
405
+ * @private
406
+ */
403
407
  _getInstanceId() {
404
408
  const bindExpr = this.getBindingExpr();
405
409
  // console.log('_getInstanceId bindExpr ', bindExpr);
406
410
  if (bindExpr.startsWith('instance(')) {
407
411
  this.instanceId = XPathUtil.getInstanceId(bindExpr);
408
- return this.instanceId;
412
+ return;
409
413
  }
410
- if (this.instanceId) {
411
- return this.instanceId;
414
+ if(!this.instanceId && this.parentNode.nodeName === 'FX-BIND'){
415
+ let parent = this.parentNode;
416
+ while(parent && !this.instanceId){
417
+ const ref = parent.getBindingExpr();
418
+ if (ref.startsWith('instance(')) {
419
+ this.instanceId = XPathUtil.getInstanceId(ref);
420
+ return;
421
+ }
422
+ if(parent.parentNode.nodeName !== 'FX-BIND'){
423
+ this.instanceId = 'default';
424
+ break;
425
+ }
426
+ parent = parent.parentNode;
427
+ }
412
428
  }
413
- return 'default';
429
+ this.instanceId = 'default';
414
430
  }
431
+
432
+
433
+
415
434
  }
435
+
416
436
  if (!customElements.get('fx-bind')) {
417
437
  customElements.define('fx-bind', FxBind);
418
438
  }
package/src/fx-model.js CHANGED
@@ -402,7 +402,7 @@ export class FxModel extends HTMLElement {
402
402
  modelItem.required = compute;
403
403
  this.formElement.addToRefresh(modelItem); // let fore know that modelItem needs refresh
404
404
  if (!modelItem.node.textContent) {
405
- console.log('validation failed on modelitem ', modelItem);
405
+ console.log('node is required but has no value ', XPathUtil.getDocPath(modelItem.node));
406
406
  valid = false;
407
407
  }
408
408
  // if (!compute) valid = false;
@@ -42,7 +42,6 @@ export class FxContainer extends foreElementMixin(HTMLElement) {
42
42
  } );
43
43
  */
44
44
 
45
- this.setAttribute('tabindex','0');
46
45
  }
47
46
 
48
47
  /**
@@ -444,11 +444,10 @@ export function evaluateXPath(xpath, contextNode, formElement, variables = {}, o
444
444
  */
445
445
  export function evaluateXPath(xpath, contextNode, formElement, variables = {}, options={}) {
446
446
  try{
447
- console.log('evaluateXPath',xpath);
448
447
  const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
449
448
  const variablesInScope = getVariablesInScope(formElement);
450
449
 
451
- return fxEvaluateXPath(
450
+ const result = fxEvaluateXPath(
452
451
  xpath,
453
452
  contextNode,
454
453
  null,
@@ -465,6 +464,8 @@ export function evaluateXPath(xpath, contextNode, formElement, variables = {}, o
465
464
  language: options.language || evaluateXPath.XPATH_3_1
466
465
  },
467
466
  );
467
+ // console.log('evaluateXPath',xpath, result);
468
+ return result;
468
469
  }catch (e){
469
470
  formElement.dispatchEvent(new CustomEvent('error', {
470
471
  composed: false,
@@ -506,7 +507,7 @@ export function evaluateXPathToFirstNode(xpath, contextNode, formElement) {
506
507
  try{
507
508
  const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
508
509
  const variablesInScope = getVariablesInScope(formElement);
509
- return fxEvaluateXPathToFirstNode(xpath, contextNode, null, variablesInScope, {
510
+ const result = fxEvaluateXPathToFirstNode(xpath, contextNode, null, variablesInScope, {
510
511
  defaultFunctionNamespaceURI: XFORMS_NAMESPACE_URI,
511
512
  moduleImports: {
512
513
  xf: XFORMS_NAMESPACE_URI,
@@ -515,6 +516,8 @@ export function evaluateXPathToFirstNode(xpath, contextNode, formElement) {
515
516
  functionNameResolver,
516
517
  namespaceResolver,
517
518
  });
519
+ // console.log('evaluateXPathToFirstNode',xpath, result);
520
+ return result;
518
521
  } catch (e){
519
522
  formElement.dispatchEvent(new CustomEvent('error', {
520
523
  composed: false,
@@ -542,7 +545,7 @@ export function evaluateXPathToNodes(xpath, contextNode, formElement) {
542
545
  const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
543
546
  const variablesInScope = getVariablesInScope(formElement);
544
547
 
545
- return fxEvaluateXPathToNodes(xpath, contextNode, null, variablesInScope, {
548
+ const result = fxEvaluateXPathToNodes(xpath, contextNode, null, variablesInScope, {
546
549
  currentContext: {formElement},
547
550
  functionNameResolver,
548
551
  moduleImports: {
@@ -550,6 +553,8 @@ export function evaluateXPathToNodes(xpath, contextNode, formElement) {
550
553
  },
551
554
  namespaceResolver,
552
555
  });
556
+ // console.log('evaluateXPathToNodes',xpath, result);
557
+ return result;
553
558
  }catch (e){
554
559
  formElement.dispatchEvent(new CustomEvent('error', {
555
560
  composed: false,