@jinntec/fore 1.10.0 → 1.10.2
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/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/package.json +1 -1
- package/resources/fore.css +2 -41
- package/src/actions/abstract-action.js +51 -62
- package/src/actions/fx-call.js +9 -0
- package/src/actions/fx-delete.js +1 -1
- package/src/actions/fx-insert.js +8 -4
- package/src/actions/fx-load.js +5 -2
- package/src/actions/fx-reload.js +1 -1
- package/src/actions/fx-send.js +8 -3
- package/src/actions/fx-setfocus.js +6 -1
- package/src/actions/fx-toggle.js +1 -0
- package/src/fore.js +3 -222
- package/src/fx-bind.js +1 -1
- package/src/fx-fore.js +96 -89
- package/src/fx-model.js +31 -7
- package/src/fx-submission.js +5 -0
- package/src/tools/fx-action-log.js +1 -1
- package/src/ui/abstract-control.js +18 -39
- package/src/ui/fx-control.js +12 -12
- package/src/ui/fx-repeat-attributes.js +2 -2
- package/src/ui/fx-repeat.js +12 -1
- package/src/ui/fx-repeatitem.js +2 -8
- package/src/ui/fx-switch.js +63 -40
- package/src/ui/fx-trigger.js +3 -13
- package/src/xpath-evaluation.js +215 -83
- package/src/xpath-util.js +138 -130
package/src/ui/fx-repeat.js
CHANGED
|
@@ -207,13 +207,17 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/*
|
|
210
211
|
this.touchedPaths = new Set();
|
|
211
212
|
const instance = XPathUtil.resolveInstance(this, this.ref);
|
|
212
213
|
const depTrackDomfacade = new DependencyNotifyingDomFacade((node) => {
|
|
213
214
|
this.touchedPaths.add(XPathUtil.getPath(node, instance));
|
|
214
215
|
});
|
|
215
216
|
const rawNodeset = evaluateXPath(this.ref, inscope, this, {}, {}, depTrackDomfacade );
|
|
216
|
-
|
|
217
|
+
*/
|
|
218
|
+
const rawNodeset = evaluateXPath(this.ref, inscope, this);
|
|
219
|
+
|
|
220
|
+
// console.log('Touched!', this.ref, [...this.touchedPaths].join(', '));
|
|
217
221
|
if (rawNodeset.length === 1 && Array.isArray(rawNodeset[0])) {
|
|
218
222
|
// This XPath likely returned an XPath array. Just collapse to that array
|
|
219
223
|
this.nodeset = rawNodeset[0];
|
|
@@ -229,6 +233,13 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
229
233
|
// console.time('repeat-refresh', this);
|
|
230
234
|
this._evalNodeset();
|
|
231
235
|
|
|
236
|
+
// ### register ourselves as boundControl
|
|
237
|
+
/*
|
|
238
|
+
const modelItem = this.getModelItem();
|
|
239
|
+
if (!modelItem.boundControls.includes(this)) {
|
|
240
|
+
modelItem.boundControls.push(this);
|
|
241
|
+
}
|
|
242
|
+
*/
|
|
232
243
|
// console.log('repeat refresh nodeset ', this.nodeset);
|
|
233
244
|
// console.log('repeatCount', this.repeatCount);
|
|
234
245
|
|
package/src/ui/fx-repeatitem.js
CHANGED
|
@@ -91,15 +91,9 @@ export class FxRepeatitem extends foreElementMixin(HTMLElement) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (this.modelItem && !this.modelItem.relevant) {
|
|
94
|
-
|
|
95
|
-
// this.style.display = 'none';
|
|
96
|
-
this.style.display = 'none';
|
|
94
|
+
this.setAttribute('nonrelevant','');
|
|
97
95
|
} else {
|
|
98
|
-
|
|
99
|
-
// Fore.fadeInElement(this);
|
|
100
|
-
// }
|
|
101
|
-
// this.style.display = this.display;
|
|
102
|
-
this.style.display = 'block';
|
|
96
|
+
this.setAttribute('relevant','');
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
/*
|
package/src/ui/fx-switch.js
CHANGED
|
@@ -18,7 +18,10 @@ class FxSwitch extends FxContainer {
|
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
this.formerCase = {};
|
|
21
|
+
this.selectedCase = null;
|
|
22
|
+
this.cases = null;
|
|
21
23
|
}
|
|
24
|
+
|
|
22
25
|
connectedCallback() {
|
|
23
26
|
if (super.connectedCallback) {
|
|
24
27
|
super.connectedCallback();
|
|
@@ -37,63 +40,83 @@ class FxSwitch extends FxContainer {
|
|
|
37
40
|
</style>
|
|
38
41
|
${html}
|
|
39
42
|
`;
|
|
43
|
+
this.cases = [];
|
|
44
|
+
this.formerCase=null;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
async refresh(force) {
|
|
43
48
|
super.refresh();
|
|
44
49
|
// console.log('refresh on switch ');
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
if(this.cases.length === 0){
|
|
51
|
+
this.cases = Array.from(this.querySelectorAll(':scope > fx-case'));
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
if (this.isBound()) {
|
|
48
|
-
|
|
49
|
-
const name = caseElem.getAttribute('name');
|
|
50
|
-
if (name === this.modelItem?.value) {
|
|
51
|
-
Fore.dispatch(caseElem,'select',{});
|
|
52
|
-
caseElem.classList.add('selected-case');
|
|
53
|
-
selectedCase = caseElem;
|
|
54
|
-
} else {
|
|
55
|
-
if(caseElem.classList.contains('selected-case')){
|
|
56
|
-
Fore.dispatch(caseElem,'deselect',{});
|
|
57
|
-
}
|
|
58
|
-
caseElem.classList.remove('selected-case');
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
62
|
-
selectedCase = this.querySelector(':scope > .selected-case');
|
|
63
|
-
// if none is selected select the first as default
|
|
64
|
-
if (!selectedCase) {
|
|
65
|
-
selectedCase = cases[0]; // if nothing is selected use the first case
|
|
66
|
-
Fore.dispatch(selectedCase,'select',{});
|
|
67
|
-
selectedCase.classList.add('selected-case');
|
|
68
|
-
}
|
|
55
|
+
this._handleBoundSwitch();
|
|
69
56
|
}
|
|
70
|
-
if(this.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
v.classList.remove('visited');
|
|
74
|
-
});
|
|
57
|
+
if(!this.selectedCase){
|
|
58
|
+
this.selectedCase = this.cases[0]; // first is always default
|
|
59
|
+
this.toggle(this.selectedCase);
|
|
75
60
|
}
|
|
76
61
|
|
|
77
|
-
Fore.refreshChildren(selectedCase,force);
|
|
78
|
-
this.formerCase = selectedCase;
|
|
62
|
+
Fore.refreshChildren(this.selectedCase,force);
|
|
79
63
|
}
|
|
80
64
|
|
|
65
|
+
_dispatchEvents(){
|
|
66
|
+
if(this.formerCase && this.formerCase !== this.selectedCase){
|
|
67
|
+
Fore.dispatch(this.formerCase,'deselect',{});
|
|
68
|
+
}
|
|
69
|
+
if(this.selectedCase.classList.contains('selected-case')){
|
|
70
|
+
Fore.dispatch(this.selectedCase,'select',{});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_resetVisited(){
|
|
75
|
+
const visited = this.selectedCase.querySelectorAll('.visited');
|
|
76
|
+
Array.from(visited).forEach(v =>{
|
|
77
|
+
v.classList.remove('visited');
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* handles switches being bound. If modelItem value matches the 'name' attribute that case will be toggled.
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
_handleBoundSwitch() {
|
|
86
|
+
Array.from(this.cases).forEach(caseElem => {
|
|
87
|
+
const name = caseElem.getAttribute('name');
|
|
88
|
+
if (name === this.modelItem?.value) {
|
|
89
|
+
this.toggle(caseElem);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Activates a fx-case element by switching CSS classes.
|
|
96
|
+
* Dispatches 'select' and 'deselect' events as appropriate.
|
|
97
|
+
*
|
|
98
|
+
* @param caseElement the fx-case element to activate
|
|
99
|
+
*/
|
|
81
100
|
toggle(caseElement) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
this.formerCase = this.selectedCase;
|
|
102
|
+
this.selectedCase = caseElement;
|
|
103
|
+
Array.from(this.cases).forEach(c => {
|
|
104
|
+
if (c === this.selectedCase) {
|
|
105
|
+
c.classList.remove('deselected-case');
|
|
86
106
|
c.classList.add('selected-case');
|
|
87
|
-
|
|
88
|
-
this.refresh();
|
|
107
|
+
c.inert = false;
|
|
89
108
|
} else {
|
|
90
|
-
// eslint-disable-next-line no-param-reassign
|
|
91
|
-
if(c.classList.contains('selected-case')){
|
|
92
|
-
Fore.dispatch(c,'deselect',{});
|
|
93
|
-
}
|
|
94
109
|
c.classList.remove('selected-case');
|
|
110
|
+
c.classList.add('deselected-case');
|
|
111
|
+
c.inert = true;
|
|
112
|
+
this._resetVisited();
|
|
95
113
|
}
|
|
96
114
|
});
|
|
115
|
+
|
|
116
|
+
if(this.selectedCase !== caseElement){
|
|
117
|
+
this.selectedCase = caseElement;
|
|
118
|
+
}
|
|
119
|
+
this._dispatchEvents();
|
|
97
120
|
}
|
|
98
121
|
}
|
|
99
122
|
|
package/src/ui/fx-trigger.js
CHANGED
|
@@ -116,19 +116,9 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// console.log('fx-button refresh');
|
|
123
|
-
|
|
124
|
-
const elements = this.querySelectorAll(':scope > *');
|
|
125
|
-
elements.forEach(element => {
|
|
126
|
-
if (typeof element.refresh === 'function') {
|
|
127
|
-
element.refresh();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
*/
|
|
119
|
+
async refresh() {
|
|
120
|
+
super.refresh();
|
|
121
|
+
}
|
|
132
122
|
}
|
|
133
123
|
|
|
134
124
|
if (!customElements.get('fx-trigger')) {
|
package/src/xpath-evaluation.js
CHANGED
|
@@ -418,6 +418,7 @@ function getVariablesInScope(formElement) {
|
|
|
418
418
|
* @param {Node} contextNode The start of the XPath
|
|
419
419
|
* @param {{parentNode}|ForeElementMixin} formElement The form element associated to the XPath
|
|
420
420
|
*/
|
|
421
|
+
/*
|
|
421
422
|
export function evaluateXPath(xpath, contextNode, formElement, variables = {}, options={}, domFacade = null) {
|
|
422
423
|
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
423
424
|
const variablesInScope = getVariablesInScope(formElement);
|
|
@@ -440,7 +441,59 @@ export function evaluateXPath(xpath, contextNode, formElement, variables = {}, o
|
|
|
440
441
|
},
|
|
441
442
|
);
|
|
442
443
|
}
|
|
444
|
+
*/
|
|
445
|
+
export function evaluateXPath(xpath, contextNode, formElement, variables = {}, options={}) {
|
|
446
|
+
try{
|
|
447
|
+
console.log('evaluateXPath',xpath);
|
|
448
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
449
|
+
const variablesInScope = getVariablesInScope(formElement);
|
|
450
|
+
|
|
451
|
+
return fxEvaluateXPath(
|
|
452
|
+
xpath,
|
|
453
|
+
contextNode,
|
|
454
|
+
null,
|
|
455
|
+
{...variablesInScope, ...variables},
|
|
456
|
+
fxEvaluateXPath.ALL_RESULTS_TYPE,
|
|
457
|
+
{
|
|
458
|
+
debug: true,
|
|
459
|
+
currentContext: {formElement, variables},
|
|
460
|
+
moduleImports: {
|
|
461
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
462
|
+
},
|
|
463
|
+
functionNameResolver,
|
|
464
|
+
namespaceResolver,
|
|
465
|
+
language: options.language || evaluateXPath.XPATH_3_1
|
|
466
|
+
},
|
|
467
|
+
);
|
|
468
|
+
}catch (e){
|
|
469
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
470
|
+
composed: false,
|
|
471
|
+
bubbles: true,
|
|
472
|
+
detail: {
|
|
473
|
+
origin: formElement,
|
|
474
|
+
message: `Expression '${xpath}' failed`,
|
|
475
|
+
expr:xpath,
|
|
476
|
+
level:'Error'
|
|
477
|
+
},
|
|
478
|
+
}));
|
|
443
479
|
|
|
480
|
+
/*
|
|
481
|
+
formElement.dispatchEvent(
|
|
482
|
+
new CustomEvent('error', {
|
|
483
|
+
composed: false,
|
|
484
|
+
bubbles: true,
|
|
485
|
+
cancelable:true,
|
|
486
|
+
detail: {
|
|
487
|
+
origin: formElement,
|
|
488
|
+
message: `Expression '${xpath}' failed`,
|
|
489
|
+
expr:xpath,
|
|
490
|
+
level:'Error'},
|
|
491
|
+
}),
|
|
492
|
+
);
|
|
493
|
+
*/
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
444
497
|
/**
|
|
445
498
|
* Evaluate an XPath to the first Node
|
|
446
499
|
*
|
|
@@ -450,17 +503,30 @@ export function evaluateXPath(xpath, contextNode, formElement, variables = {}, o
|
|
|
450
503
|
* @return {Node} The first node found by the XPath
|
|
451
504
|
*/
|
|
452
505
|
export function evaluateXPathToFirstNode(xpath, contextNode, formElement) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
506
|
+
try{
|
|
507
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
508
|
+
const variablesInScope = getVariablesInScope(formElement);
|
|
509
|
+
return fxEvaluateXPathToFirstNode(xpath, contextNode, null, variablesInScope, {
|
|
510
|
+
defaultFunctionNamespaceURI: XFORMS_NAMESPACE_URI,
|
|
511
|
+
moduleImports: {
|
|
512
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
513
|
+
},
|
|
514
|
+
currentContext: {formElement},
|
|
515
|
+
functionNameResolver,
|
|
516
|
+
namespaceResolver,
|
|
517
|
+
});
|
|
518
|
+
} catch (e){
|
|
519
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
520
|
+
composed: false,
|
|
521
|
+
bubbles: true,
|
|
522
|
+
detail: {
|
|
523
|
+
origin: formElement,
|
|
524
|
+
message: `Expression '${xpath}' failed`,
|
|
525
|
+
expr:xpath,
|
|
526
|
+
level:'Error'
|
|
527
|
+
},
|
|
528
|
+
}));
|
|
529
|
+
}
|
|
464
530
|
}
|
|
465
531
|
|
|
466
532
|
/**
|
|
@@ -472,17 +538,30 @@ export function evaluateXPathToFirstNode(xpath, contextNode, formElement) {
|
|
|
472
538
|
* @return {Node[]} All nodes
|
|
473
539
|
*/
|
|
474
540
|
export function evaluateXPathToNodes(xpath, contextNode, formElement) {
|
|
475
|
-
|
|
476
|
-
|
|
541
|
+
try{
|
|
542
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
543
|
+
const variablesInScope = getVariablesInScope(formElement);
|
|
477
544
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
545
|
+
return fxEvaluateXPathToNodes(xpath, contextNode, null, variablesInScope, {
|
|
546
|
+
currentContext: {formElement},
|
|
547
|
+
functionNameResolver,
|
|
548
|
+
moduleImports: {
|
|
549
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
550
|
+
},
|
|
551
|
+
namespaceResolver,
|
|
552
|
+
});
|
|
553
|
+
}catch (e){
|
|
554
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
555
|
+
composed: false,
|
|
556
|
+
bubbles: true,
|
|
557
|
+
detail: {
|
|
558
|
+
origin: formElement,
|
|
559
|
+
message: `Expression '${xpath}' failed`,
|
|
560
|
+
expr:xpath,
|
|
561
|
+
level:'Error'
|
|
562
|
+
},
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
486
565
|
}
|
|
487
566
|
|
|
488
567
|
/**
|
|
@@ -494,17 +573,30 @@ export function evaluateXPathToNodes(xpath, contextNode, formElement) {
|
|
|
494
573
|
* @return {boolean}
|
|
495
574
|
*/
|
|
496
575
|
export function evaluateXPathToBoolean(xpath, contextNode, formElement) {
|
|
497
|
-
|
|
498
|
-
|
|
576
|
+
try{
|
|
577
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
578
|
+
const variablesInScope = getVariablesInScope(formElement);
|
|
499
579
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
580
|
+
return fxEvaluateXPathToBoolean(xpath, contextNode, null, variablesInScope, {
|
|
581
|
+
currentContext: {formElement},
|
|
582
|
+
functionNameResolver,
|
|
583
|
+
moduleImports: {
|
|
584
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
585
|
+
},
|
|
586
|
+
namespaceResolver,
|
|
587
|
+
});
|
|
588
|
+
}catch (e){
|
|
589
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
590
|
+
composed: false,
|
|
591
|
+
bubbles: true,
|
|
592
|
+
detail: {
|
|
593
|
+
origin: formElement,
|
|
594
|
+
message: `Expression '${xpath}' failed`,
|
|
595
|
+
expr:xpath,
|
|
596
|
+
level:'Error'
|
|
597
|
+
},
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
508
600
|
}
|
|
509
601
|
|
|
510
602
|
/**
|
|
@@ -525,17 +617,30 @@ export function evaluateXPathToString(
|
|
|
525
617
|
domFacade = null,
|
|
526
618
|
namespaceReferenceNode = formElement,
|
|
527
619
|
) {
|
|
528
|
-
|
|
529
|
-
|
|
620
|
+
try{
|
|
621
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
622
|
+
const variablesInScope = getVariablesInScope(formElement);
|
|
530
623
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
624
|
+
return fxEvaluateXPathToString(xpath, contextNode, domFacade, variablesInScope, {
|
|
625
|
+
currentContext: {formElement},
|
|
626
|
+
functionNameResolver,
|
|
627
|
+
moduleImports: {
|
|
628
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
629
|
+
},
|
|
630
|
+
namespaceResolver,
|
|
631
|
+
});
|
|
632
|
+
}catch (e) {
|
|
633
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
634
|
+
composed: false,
|
|
635
|
+
bubbles: true,
|
|
636
|
+
detail: {
|
|
637
|
+
origin: formElement,
|
|
638
|
+
message: `Expression '${xpath}' failed`,
|
|
639
|
+
expr:xpath,
|
|
640
|
+
level:'Error'
|
|
641
|
+
},
|
|
642
|
+
}));
|
|
643
|
+
}
|
|
539
644
|
}
|
|
540
645
|
|
|
541
646
|
/**
|
|
@@ -556,22 +661,31 @@ export function evaluateXPathToStrings(
|
|
|
556
661
|
domFacade = null,
|
|
557
662
|
namespaceReferenceNode = formElement,
|
|
558
663
|
) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
xpath,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
xf: XFORMS_NAMESPACE_URI,
|
|
664
|
+
try{
|
|
665
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
666
|
+
return fxEvaluateXPathToStrings( xpath, contextNode, domFacade,
|
|
667
|
+
{},
|
|
668
|
+
{
|
|
669
|
+
currentContext: {formElement},
|
|
670
|
+
functionNameResolver,
|
|
671
|
+
moduleImports: {
|
|
672
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
673
|
+
},
|
|
674
|
+
namespaceResolver,
|
|
571
675
|
},
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
676
|
+
);
|
|
677
|
+
} catch (e){
|
|
678
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
679
|
+
composed: false,
|
|
680
|
+
bubbles: true,
|
|
681
|
+
detail: {
|
|
682
|
+
origin: formElement,
|
|
683
|
+
message: `Expression '${xpath}' failed`,
|
|
684
|
+
expr:xpath,
|
|
685
|
+
level:'Error'
|
|
686
|
+
},
|
|
687
|
+
}));
|
|
688
|
+
}
|
|
575
689
|
}
|
|
576
690
|
|
|
577
691
|
/**
|
|
@@ -592,17 +706,30 @@ export function evaluateXPathToNumber(
|
|
|
592
706
|
domFacade = null,
|
|
593
707
|
namespaceReferenceNode = formElement,
|
|
594
708
|
) {
|
|
595
|
-
|
|
596
|
-
|
|
709
|
+
try{
|
|
710
|
+
const namespaceResolver = createNamespaceResolverForNode(xpath, contextNode, formElement);
|
|
711
|
+
const variablesInScope = getVariablesInScope(formElement);
|
|
597
712
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
713
|
+
return fxEvaluateXPathToNumber(xpath, contextNode, domFacade, variablesInScope, {
|
|
714
|
+
currentContext: {formElement},
|
|
715
|
+
functionNameResolver,
|
|
716
|
+
moduleImports: {
|
|
717
|
+
xf: XFORMS_NAMESPACE_URI,
|
|
718
|
+
},
|
|
719
|
+
namespaceResolver,
|
|
720
|
+
});
|
|
721
|
+
}catch (e) {
|
|
722
|
+
formElement.dispatchEvent(new CustomEvent('error', {
|
|
723
|
+
composed: false,
|
|
724
|
+
bubbles: true,
|
|
725
|
+
detail: {
|
|
726
|
+
origin: formElement,
|
|
727
|
+
message: `Expression '${xpath}' failed`,
|
|
728
|
+
expr:xpath,
|
|
729
|
+
level:'Error'
|
|
730
|
+
},
|
|
731
|
+
}));
|
|
732
|
+
}
|
|
606
733
|
}
|
|
607
734
|
|
|
608
735
|
const contextFunction = (dynamicContext, string) => {
|
|
@@ -844,25 +971,30 @@ const instance = (dynamicContext, string) => {
|
|
|
844
971
|
{namespaceResolver: xhtmlNamespaceResolver},
|
|
845
972
|
);
|
|
846
973
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
974
|
+
let lookup = null;
|
|
975
|
+
if(string === null || string === 'default'){
|
|
976
|
+
lookup = formElement.getModel().getDefaultInstance();
|
|
977
|
+
}else{
|
|
978
|
+
lookup = formElement.getModel().getInstance(string);
|
|
979
|
+
if(!lookup){
|
|
980
|
+
document.querySelector('fx-fore').dispatchEvent(new CustomEvent('error', {
|
|
981
|
+
composed: true,
|
|
982
|
+
bubbles: true,
|
|
983
|
+
detail: {
|
|
984
|
+
origin: 'functions',
|
|
985
|
+
message: `Instance not found '${localName}'`,
|
|
986
|
+
level:'Error'
|
|
987
|
+
},
|
|
988
|
+
}));
|
|
989
|
+
}
|
|
990
|
+
}
|
|
856
991
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
return null;
|
|
862
|
-
}
|
|
863
|
-
return context;
|
|
992
|
+
const context = lookup.getDefaultContext();
|
|
993
|
+
if (!context) {
|
|
994
|
+
debugger;
|
|
995
|
+
return null;
|
|
864
996
|
}
|
|
865
|
-
return
|
|
997
|
+
return context;
|
|
866
998
|
};
|
|
867
999
|
|
|
868
1000
|
registerCustomXPathFunction(
|